8000 Merge branch '3.1' · symfony/symfony@37c9c39 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37c9c39

Browse files
Merge branch '3.1'
* 3.1: [travis] Don't use parallel on HHVM [HttpKernel] Fix RequestDataCollector starting the session [appveyor] Ignore STATUS_HEAP_CORRUPTION errors on Windows [FrameworkBundle] Skip redis cache pools test on failed connection Fixed forwarded request data in templates [Security] Fix DebugAccessDecisionManager when object is not a scalar Skip some tests on HHVM due to a PHPunit bug Use the Trusty Travis infrastructure for HHVM builds LdapUserProvider: add missing argument type doc Fixed issue with missing argument in the abstract service definition for the ldap user provider Add 3.1 to PR template branch row, remove 2.3 Improve memory efficiency [Console] Fix BC break introduced by #18101 document method name changes in Voter class add missing hint for vote() argument type [#18838] add a test to avoid regressions bumped Symfony version to 3.1.1 updated VERSION for 3.1.0 updated CHANGELOG for 3.1.0 Conflicts: src/Symfony/Component/HttpKernel/Kernel.php
2 parents 313c8c0 + 98303d3 commit 37c9c39

File tree

22 files changed

+176
-25
lines changed

22 files changed

+176
-25
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| Q | A
22
| ------------- | ---
3-
| Branch? | "master" for new features / 2.3, 2.7, 2.8 or 3.0 for fixes
3+
| Branch? | "master" for new features / 2.7, 2.8, 3.0 or 3.1 for fixes
44
| Bug fix? | yes/no
55
| New feature? | yes/no
66
| BC breaks? | yes/no

.travis.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ env:
1919

2020
matrix:
2121
include:
22+
# Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version
2223
- php: hhvm
24+
sudo: required
25+
dist: trusty
26+
group: edge
2327
- php: 5.5
2428
- php: 5.6
2529
env: deps=high
@@ -37,14 +41,15 @@ services:
3741
- redis-server
3842

3943
before_install:
44+
- stty cols 120
10000
4045
- mkdir /tmp/slapd
4146
- slapd -f src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf -h ldap://localhost:3389 &
4247
- PHP=$TRAVIS_PHP_VERSION
4348
# Matrix lines for intermediate PHP versions are skipped for pull requests
44-
- if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && $PHP != hhvm && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; skip=1; fi
49+
- if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && ! $PHP = hhvm* && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; skip=1; fi
4550
# A sigchild-enabled-PHP is used to test the Process component on the lowest PHP matrix line
4651
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi
47-
- if [[ $PHP != hhvm ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi
52+
- if [[ ! $PHP = hhvm* ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi
4853
- if [[ ! $skip ]]; then echo memory_limit = -1 >> $INI_FILE; fi
4954
- if [[ ! $skip ]]; then echo session.gc_probability = 0 >> $INI_FILE; fi
5055
- if [[ ! $skip && $PHP = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi
@@ -53,9 +58,9 @@ before_install:
5358
- if [[ ! $skip && $PHP = 7.* ]]; then (echo yes | pecl install -f apcu-5.1.2 && echo apc.enable_cli = 1 >> $INI_FILE); fi
5459
- if [[ ! $deps && $PHP = 5.* ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> $INI_FILE); fi
5560
- if [[ ! $skip && $PHP = 5.* ]]; then pecl install -f memcached-2.1.0; fi
56-
- if [[ ! $skip && $PHP != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi
57-
- if [[ ! $skip && $PHP != hhvm ]]; then echo extension = redis.so >> $INI_FILE; fi;
58-
- if [[ ! $skip && $PHP != hhvm ]]; then phpenv config-rm xdebug.ini; fi
61+
- if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = ldap.so >> $INI_FILE; fi
62+
- if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = redis.so >> $INI_FILE; fi;
63+
- if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini; fi
5964
- if [[ ! $skip ]]; then composer self-update --stable; fi
6065
- if [[ ! $skip ]]; then cp .composer/* ~/.composer/; fi
6166
- if [[ ! $skip ]]; then ./phpunit install; fi
@@ -75,12 +80,13 @@ install:
7580
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
7681
- if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi
7782
- if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi
78-
- if [[ $PHP != hhvm ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
83+
- if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
7984

8085
script:
8186
- if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi
82-
- if [[ ! $deps ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi
83-
- if [[ ! $deps ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
87+
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi
88+
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
89+
- if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data; fi
8490
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
8591
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi
8692
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi

CHANGELOG-3.1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ in 3.1 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.1.0...v3.1.1
99

10+
* 3.1.0 (2016-05-30)
11+
12+
* bug #18889 [Console] SymfonyStyle: Fix alignment/prefixing of multi-line comments (chalasr)
13+
* bug #18907 [Routing] Fix the annotation loader taking a class constant as a beginning of a class name (jakzal, nicolas-grekas)
14+
* bug #18899 [Yaml] search for colons in strings only (xabbuh)
15+
1016
* 3.1.0-RC1 (2016-05-26)
1117

1218
* bug #18879 [Console] SymfonyStyle: Align multi-line/very-long-line blocks (chalasr)

UPGRADE-3.0.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,9 @@ UPGRADE FROM 2.x to 3.0
10421042
introduced in 2.8, and move your voting logic to the to the `supports($attribute, $subject)`
10431043
and `voteOnAttribute($attribute, $object, TokenInterface $token)` methods.
10441044

1045+
* The `vote()` method from the `VoterInterface` was changed to now accept arbitrary
1046+
types, and not only objects.
1047+
10451048
* The `supportsClass` and `supportsAttribute` methods were
10461049
removed from the `VoterInterface` interface.
10471050

@@ -1083,7 +1086,7 @@ UPGRADE FROM 2.x to 3.0
10831086
}
10841087
```
10851088

1086-
* The `AbstractVoter::isGranted()` method have been replaced by `AbstractVoter::voteOnAttribute()`.
1089+
* The `AbstractVoter::isGranted()` method has been replaced by `Voter::voteOnAttribute()`.
10871090

10881091
Before:
10891092

@@ -1102,7 +1105,7 @@ UPGRADE FROM 2.x to 3.0
11021105
After:
11031106

11041107
```php
1105-
class MyVoter extends AbstractVoter
1108+
class MyVoter extends Voter
11061109
{
11071110
protected function voteOnAttribute($attribute, $object, TokenInterface $token)
11081111
{
@@ -1113,8 +1116,8 @@ UPGRADE FROM 2.x to 3.0
11131116
}
11141117
```
11151118

1116-
* The `supportsAttribute()` and `supportsClass()` methods of classes `AuthenticatedVoter`, `ExpressionVoter`
1117-
and `RoleVoter` have been removed.
1119+
* The `supportsAttribute()` and `supportsClass()` methods of the `AuthenticatedVoter`, `ExpressionVoter`,
1120+
and `RoleVoter` classes have been removed.
11181121

11191122
* The `intention` option was renamed to `csrf_token_id` for all the authentication listeners.
11201123

phpunit

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
5353
chdir("phpunit-$PHPUNIT_VERSION");
5454
passthru("$COMPOSER remove --no-update phpspec/prophecy");
5555
passthru("$COMPOSER remove --no-update symfony/yaml");
56+
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
57+
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
58+
}
5659
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.1@dev\"");
5760
passthru("$COMPOSER install --prefer-dist --no-progress --ansi", $exit);
5861
if ($exit) {
@@ -170,8 +173,11 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
170173
unlink($file);
171174
}
172175

173-
// Fail on any individual component failures but ignore STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) and STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) on Windows when APCu is enabled
174-
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || (-1073740791 !== $procStatus && -1073741819 !== $procStatus))) {
176+
// Fail on any individual component failures but ignore some error codes on Windows when APCu is enabled:
177+
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
178+
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
179+
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
180+
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) {
175181
$exit = $procStatus;
176182
echo "\033[41mKO\033[0m $component\n\n";
177183
} else {

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function process(ContainerBuilder $container)
3838
throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id));
3939
}
4040
$container->setAlias($serviceId = 'console.command.'.strtolower(str_replace('\\', '_', $class)), $id);
41-
$serviceIds[] = $serviceId;
41+
$serviceIds[] = $definition->isPublic() ? $id : $serviceId;
4242
}
4343

4444
$container->setParameter('console.command.ids', $serviceIds);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ public function testProcess($public)
4545
$this->assertTrue($container->hasDefinition($alias));
4646
}
4747

48+
$id = $public ? 'my-command' : 'console.command.symfony_bundle_frameworkbundle_tests_dependencyinjection_compiler_mycommand';
4849
$this->assertTrue($container->hasParameter('console.command.ids'));
49-
$this->assertSame(array('console.command.symfony_bundle_frameworkbundle_tests_dependencyinjection_compiler_mycommand'), $container->getParameter('console.command.ids'));
50+
$this->assertSame(array($id), $container->getParameter('console.command.ids'));
5051
}
5152

5253
public function visibilityProvider()

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1515
use Symfony\Component\Cache\Adapter\RedisAdapter;
16+
use Symfony\Component\Cache\Exception\InvalidArgumentException;
1617

1718
class CachePoolsTest extends WebTestCase
1819
{
@@ -33,6 +34,11 @@ public function testRedisCachePools()
3334
throw $e;
3435
}
3536
$this->markTestSkipped($e->getMessage());
37+
} catch (InvalidArgumentException $e) {
38+
if (0 !== strpos($e->getMessage(), 'Redis connection failed')) {
39+
throw $e;
40+
}
41+
$this->markTestSkipped($e->getMessage());
3642
}
3743
}
3844

src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
<argument /> <!-- default_roles -->
128128
<argument /> <!-- uid key -->
129129
<argument /> <!-- filter -->
130+
<argument /> <!-- password_attribute -->
130131
</service>
131132

132133
<service id="security.user.provider.chain" class="Symfony\Component\Security\Core\User\ChainUserProvider" abstract="true" public="false" />

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{% endset %}
1414
{% endif %}
1515

16-
{% if collector.forward %}
16+
{% if collector.forward|default(false) %}
1717
{% set forward_handler %}
1818
{% import _self as helper %}
1919
{{ helper.set_handler(collector.forward.controller) }}
@@ -26,7 +26,7 @@
2626
<span class="sf-toolbar-status sf-toolbar-status-{{ request_status_code_color }}">{{ collector.statuscode }}</span>
2727
{% if collector.route %}
2828
{% if collector.redirect %}{{ include('@WebProfiler/Icon/redirect.svg') }}{% endif %}
29-
{% if collector.forward %}{{ include('@WebProfiler/Icon/forward.svg') }}{% endif %}
29+
{% if collector.forward|default(false) %}{{ include('@WebProfiler/Icon/forward.svg') }}{% endif %}
3030
<span class="sf-toolbar-label">{{ 'GET' != collector.method ? collector.method }} @</span>
3131
<span class="sf-toolbar-value sf-toolbar-info-piece-additional">{{ collector.route }}</span>
3232
{% endif %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</dl>
4545
{%- endif %}
4646

47-
{% if request_collector and request_collector.forward and request_collector.forward.controller.class is defined -%}
47+
{% if request_collector and request_collector.forward|default(false) and request_collector.forward.controller.class is defined -%}
4848
{%- set forward = request_collector.forward -%}
4949
{%- set controller = forward.controller -%}
5050
<dl class="metadata">

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function getStream()
7272
*/
7373
protected function doWrite($message, $newline)
7474
{
75-
if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) {
75+
if (false === @fwrite($this->stream, $message) || ($newline && (false === @fwrite($this->stream, PHP_EOL)))) {
7676
// should never happen
7777
throw new RuntimeException('Unable to write output.');
7878
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
3030

3131
protected function setUp()
3232
{
33+
if (defined('HHVM_VERSION')) {
34+
$this->markTestSkipped('PHPUnit_MockObject cannot mock the Memcache class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289');
35+
}
36+
3337
parent::setUp();
3438
$this->memcache = $this->getMock('Memcache');
3539
$this->storage = new MemcacheSessionHandler(

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
3131

3232
protected function setUp()
3333
{
34+
if (defined('HHVM_VERSION')) {
35+
$this->markTestSkipped('PHPUnit_MockObject cannot mock the Memcached class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289');
36+
}
37+
3438
parent::setUp();
3539

3640
if (version_compare(phpversion('memcached'), '2.2.0', '>=')) {

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ public function testReadWriteReadWithNullByte()
135135

136136
public function testReadConvertsStreamToString()
137137
{
138+
if (defined('HHVM_VERSION')) {
139+
$this->markTestSkipped('PHPUnit_MockObject cannot mock the PDOStatement class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289');
140+
}
141+
138142
$pdo = new MockPdo('pgsql');
139143
$pdo->prepareResult = $this->getMock('PDOStatement');
140144

@@ -152,6 +156,10 @@ public function testReadConvertsStreamToString()
152156

153157
public function testReadLockedConvertsStreamToString()
154158
{
159+
if (defined('HHVM_VERSION')) {
160+
$this->markTestSkipped('PHPUnit_MockObject cannot mock the PDOStatement class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289');
161+
}
162+
155163
$pdo = new MockPdo('pgsql');
156164
$selectStmt = $this->getMock('PDOStatement');
157165
$insertStmt = $this->getMock('PDOStatement');

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function collect(Request $request, Response $response, \Exception $except
130130
unset($this->controllers[$request]);
131131
}
132132

133-
if (null !== $session) {
133+
if (null !== $session && $session->isStarted()) {
134134
if ($request->attributes->has('_redirected')) {
135135
$this->data['redirect'] = $session->remove('sf_redirect');
136136
}
@@ -291,7 +291,7 @@ public function onKernelController(FilterControllerEvent $event)
291291

292292
public function onKernelResponse(FilterResponseEvent $event)
293293
{
294-
if (!$event->isMasterRequest() || !$event->getRequest()->hasSession()) {
294+
if (!$event->isMasterRequest() || !$event->getRequest()->hasSession() || !$event->getRequest()->getSession()->isStarted()) {
295295
return;
296296
}
297297

src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testFlush()
113113
$line = __LINE__ - 1;
114114

115115
ob_start();
116-
$collector = null;
116+
$collector->__destruct();
117117
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
118118
}
119119
}

src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
1313

14+
use Symfony\Component\HttpFoundation\Session\Session;
15+
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
1416
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
17+
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1518
use Symfony\Component\HttpKernel\HttpKernel;
1619
use Symfony\Component\HttpKernel\HttpKernelInterface;
1720
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
@@ -52,6 +55,20 @@ public function testCollect()
5255
$this->assertSame('application/json', $c->getContentType());
5356
}
5457

58+
public function testKernelResponseDoesNotStartSession()
59+
{
60+
$kernel = $this->getMock(HttpKernelInterface::class);
61+
$request = new Request();
62+
$session = new Session(new MockArraySessionStorage());
63+
$request->setSession($session);
64+
$response = new Response();
65+
66+
$c = new RequestDataCollector();
67+
$c->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response));
68+
69+
$this->assertFalse($session->isStarted());
70+
}
71+
5572
/**
5673
* Test various types of controller callables.
5774
*/

src/Symfony/Component/Security/Core/Authorization/DebugAccessDecisionManager.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ private function getStringRepresentation($object)
103103
}
104104

105105
if (!is_object($object)) {
106-
return sprintf('%s (%s)', gettype($object), $object);
106+
if (is_bool($object)) {
107+
return sprintf('%s (%s)', gettype($object), $object ? 'true' : 'false');
108+
}
109+
if (is_scalar($object)) {
110+
return sprintf('%s (%s)', gettype($object), $object);
111+
}
112+
113+
return gettype($object);
107114
}
108115

109116
$objectClass = class_exists('Doctrine\Common\Util\ClassUtils') ? ClassUtils::getClass($object) : get_class($object);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Core\Tests\Authorization;
13+
14+
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
15+
use Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager;
16+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
17+
18+
class DebugAccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
19+
{
20+
/**
21+
* @dataProvider provideObjectsAndLogs
22+
*/
23+
public function testDecideLog($expectedLog, $object)
24+
{
25+
$adm = new DebugAccessDecisionManager(new AccessDecisionManager());
26+
$adm->decide($this->getMock(TokenInterface::class), array('ATTRIBUTE_1'), $object);
27+
28+
$this->assertSame($expectedLog, $adm->getDecisionLog());
29+
}
30+
31+
public function provideObjectsAndLogs()
32+
{
33+
$object = new \stdClass();
34+
35+
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'NULL', 'result' => false)), null);
36+
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'boolean (true)', 'result' => false)), true);
37+
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'string (jolie string)', 'result' => false)), 'jolie string');
38+
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'integer (12345)', 'result' => false)), 12345);
39+
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'resource', 'result' => false)), fopen(__FILE__, 'r'));
40+
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'array', 'result' => false)), array());
41+
yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => sprintf('stdClass (object hash: %s)', spl_object_hash($object)), 'result' => false)), $object);
42+
}
43+
}

0 commit comments

Comments
 (0)
0