Merge branch '2.7' into 2.8

Conflicts:
	src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
	src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php
	src/Symfony/Component/Security/composer.json
This commit is contained in:
Nicolas Grekas 2015-10-06 19:12:59 +02:00
commit 72365716c2
22 changed files with 157 additions and 52 deletions

View File

@ -149,7 +149,7 @@ EOF
return; return;
} }
$refl = new \ReflectionMethod($cb[0], $cb[1]); $refl = new \ReflectionMethod($cb[0], $cb[1]);
} elseif (is_object($cb) && is_callable($cb)) { } elseif (is_object($cb) && method_exists($cb, '__invoke')) {
$refl = new \ReflectionMethod($cb, '__invoke'); $refl = new \ReflectionMethod($cb, '__invoke');
} elseif (function_exists($cb)) { } elseif (function_exists($cb)) {
$refl = new \ReflectionFunction($cb); $refl = new \ReflectionFunction($cb);

View File

@ -14,7 +14,7 @@
<service id="debug.debug_handlers_listener" class="%debug.debug_handlers_listener.class%"> <service id="debug.debug_handlers_listener" class="%debug.debug_handlers_listener.class%">
<tag name="kernel.event_subscriber" /> <tag name="kernel.event_subscriber" />
<tag name="monolog.logger" channel="php" /> <tag name="monolog.logger" channel="php" />
<argument /><!-- Exception handler --> <argument>null</argument><!-- Exception handler -->
<argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="logger" on-invalid="null" />
<argument>null</argument><!-- Log levels map for enabled error levels --> <argument>null</argument><!-- Log levels map for enabled error levels -->
<argument>null</argument> <argument>null</argument>

View File

@ -137,15 +137,17 @@ class ApplicationDescription
private function sortCommands(array $commands) private function sortCommands(array $commands)
{ {
$namespacedCommands = array(); $namespacedCommands = array();
$globalCommands = array();
foreach ($commands as $name => $command) { foreach ($commands as $name => $command) {
$key = $this->application->extractNamespace($name, 1); $key = $this->application->extractNamespace($name, 1);
if (!$key) { if (!$key) {
$key = '_global'; $globalCommands['_global'][$name] = $command;
} else {
$namespacedCommands[$key][$name] = $command;
} }
$namespacedCommands[$key][$name] = $command;
} }
ksort($namespacedCommands); ksort($namespacedCommands);
$namespacedCommands = array_merge($globalCommands, $namespacedCommands);
foreach ($namespacedCommands as &$commandsSet) { foreach ($namespacedCommands as &$commandsSet) {
ksort($commandsSet); ksort($commandsSet);

View File

@ -220,7 +220,7 @@ class Question
* *
* The normalizer can be a callable (a string), a closure or a class implementing __invoke. * The normalizer can be a callable (a string), a closure or a class implementing __invoke.
* *
* @param string|\Closure $normalizer * @param callable $normalizer
* *
* @return Question The current instance * @return Question The current instance
*/ */
@ -236,7 +236,7 @@ class Question
* *
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke. * The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
* *
* @return string|\Closure * @return callable
*/ */
public function getNormalizer() public function getNormalizer()
{ {

View File

@ -61,4 +61,52 @@ EOF;
$this->assertEquals($output, $commandTester->getDisplay(true)); $this->assertEquals($output, $commandTester->getDisplay(true));
} }
public function testExecuteListsCommandsOrder()
{
require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php');
$application = new Application();
$application->add(new \Foo6Command());
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName()), array('decorated' => false));
$output = <<<EOF
Console Tool
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
0foo
0foo:bar 0foo:bar command
EOF;
$this->assertEquals($output, trim($commandTester->getDisplay(true)));
}
public function testExecuteListsCommandsOrderRaw()
{
require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php');
$application = new Application();
$application->add(new \Foo6Command());
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName(), '--raw' => true));
$output = <<<EOF
help Displays help for a command
list Lists commands
0foo:bar 0foo:bar command
EOF;
$this->assertEquals($output, trim($commandTester->getDisplay(true)));
}
} }

View File

@ -0,0 +1,12 @@
<?php
use Symfony\Component\Console\Command\Command;
class Foo6Command extends Command
{
protected function configure()
{
$this->setName('0foo:bar')->setDescription('0foo:bar command');
}
}

View File

@ -26,8 +26,8 @@ class CustomFilterIterator extends FilterIterator
/** /**
* Constructor. * Constructor.
* *
* @param \Iterator $iterator The Iterator to filter * @param \Iterator $iterator The Iterator to filter
* @param array $filters An array of PHP callbacks * @param callable[] $filters An array of PHP callbacks
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */

View File

@ -131,7 +131,7 @@ class ControllerResolver implements ControllerResolverInterface
* *
* @param string $controller A Controller string * @param string $controller A Controller string
* *
* @return mixed A PHP callable * @return callable A PHP callable
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */

View File

@ -29,8 +29,6 @@ class FilterControllerEvent extends KernelEvent
{ {
/** /**
* The current controller. * The current controller.
*
* @var callable
*/ */
private $controller; private $controller;

View File

@ -1270,7 +1270,7 @@ class Process
* *
* @param callable|null $callback The user defined PHP callback * @param callable|null $callback The user defined PHP callback
* *
* @return callable A PHP callable * @return \Closure A PHP closure
*/ */
protected function buildCallback($callback) protected function buildCallback($callback)
{ {

View File

@ -8,7 +8,7 @@
</trans-unit> </trans-unit>
<trans-unit id="2"> <trans-unit id="2">
<source>Authentication credentials could not be found.</source> <source>Authentication credentials could not be found.</source>
<target>Yetkilendirme girdileri bulunamadı.</target> <target>Kimlik bilgileri bulunamadı.</target>
</trans-unit> </trans-unit>
<trans-unit id="3"> <trans-unit id="3">
<source>Authentication request could not be processed due to a system problem.</source> <source>Authentication request could not be processed due to a system problem.</source>
@ -16,7 +16,7 @@
</trans-unit> </trans-unit>
<trans-unit id="4"> <trans-unit id="4">
<source>Invalid credentials.</source> <source>Invalid credentials.</source>
<target>Geçersiz girdiler.</target> <target>Geçersiz kimlik bilgileri.</target>
</trans-unit> </trans-unit>
<trans-unit id="5"> <trans-unit id="5">
<source>Cookie has already been used by someone else.</source> <source>Cookie has already been used by someone else.</source>
@ -32,7 +32,7 @@
</trans-unit> </trans-unit>
<trans-unit id="8"> <trans-unit id="8">
<source>Digest nonce has expired.</source> <source>Digest nonce has expired.</source>
<target>Derleme zaman aşımı gerçekleşti.</target> <target>Derleme zaman aşımına uğradı.</target>
</trans-unit> </trans-unit>
<trans-unit id="9"> <trans-unit id="9">
<source>No authentication provider found to support the authentication token.</source> <source>No authentication provider found to support the authentication token.</source>
@ -44,7 +44,7 @@
</trans-unit> </trans-unit>
<trans-unit id="11"> <trans-unit id="11">
<source>No token could be found.</source> <source>No token could be found.</source>
<target>Bilet bulunamadı.</target> <target>Fiş bulunamadı.</target>
</trans-unit> </trans-unit>
<trans-unit id="12"> <trans-unit id="12">
<source>Username could not be found.</source> <source>Username could not be found.</source>
@ -56,11 +56,11 @@
</trans-unit> </trans-unit>
<trans-unit id="14"> <trans-unit id="14">
<source>Credentials have expired.</source> <source>Credentials have expired.</source>
<target>Girdiler zaman aşımına uğradı.</target> <target>Kimlik bilgileri zaman aşımına uğradı.</target>
</trans-unit> </trans-unit>
<trans-unit id="15"> <trans-unit id="15">
<source>Account is disabled.</source> <source>Account is disabled.</source>
<target>Hesap devre dışı bırakılmış.</target> <target>Hesap engellenmiş.</target>
</trans-unit> </trans-unit>
<trans-unit id="16"> <trans-unit id="16">
<source>Account is locked.</source> <source>Account is locked.</source>

View File

@ -102,7 +102,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoterFor2Roles($token, $vote1, $vote2) protected function getVoterFor2Roles($token, $vote1, $vote2)
{ {
$voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'); $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
$voter->expects($this->exactly(2)) $voter->expects($this->any())
->method('vote') ->method('vote')
->will($this->returnValueMap(array( ->will($this->returnValueMap(array(
array($token, null, array('ROLE_FOO'), $vote1), array($token, null, array('ROLE_FOO'), $vote1),

View File

@ -35,7 +35,10 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
const COOKIE_DELIMITER = ':'; const COOKIE_DELIMITER = ':';
protected $logger; protected $logger;
protected $options; protected $options = array(
'secure' => false,
'httponly' => true,
);
private $providerKey; private $providerKey;
private $secret; private $secret;
private $userProviders; private $userProviders;
@ -66,7 +69,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
$this->userProviders = $userProviders; $this->userProviders = $userProviders;
$this->secret = $secret; $this->secret = $secret;
$this->providerKey = $providerKey; $this->providerKey = $providerKey;
$this->options = $options; $this->options = array_merge($this->options, $options);
$this->logger = $logger; $this->logger = $logger;
} }

View File

@ -91,11 +91,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$request = new Request(); $request = new Request();
$response = new Response(); $response = new Response();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$service->logout($request, $response, $token); $service->logout($request, $response, $token);
$cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME); $cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie);
$this->assertTrue($cookie->isCleared()); $this->assertTrue($cookie->isCleared());
$this->assertSame($options['name'], $cookie->getName()); $this->assertSame($options['name'], $cookie->getName());
@ -286,13 +283,6 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$userProvider = $this->getProvider(); $userProvider = $this->getProvider();
} }
if (!isset($options['secure'])) {
$options['secure'] = false;
}
if (!isset($options['httponly'])) {
$options['httponly'] = true;
}
return $this->getMockForAbstractClass('Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices', array( return $this->getMockForAbstractClass('Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices', array(
array($userProvider), 'foosecret', 'fookey', $options, $logger, array($userProvider), 'foosecret', 'fookey', $options, $logger,
)); ));

View File

@ -313,13 +313,6 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$userProvider = $this->getProvider(); $userProvider = $this->getProvider();
} }
if (!isset($options['secure'])) {
$options['secure'] = false;
}
if (!isset($options['httponly'])) {
$options['httponly'] = true;
}
return new PersistentTokenBasedRememberMeServices(array($userProvider), 'foosecret', 'fookey', $options, $logger, new SecureRandom(sys_get_temp_dir().'/_sf2.seed')); return new PersistentTokenBasedRememberMeServices(array($userProvider), 'foosecret', 'fookey', $options, $logger, new SecureRandom(sys_get_temp_dir().'/_sf2.seed'));
} }

View File

@ -266,13 +266,6 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$userProvider = $this->getProvider(); $userProvider = $this->getProvider();
} }
if (!isset($options['secure'])) {
$options['secure'] = false;
}
if (!isset($options['httponly'])) {
$options['httponly'] = true;
}
$service = new TokenBasedRememberMeServices(array($userProvider), 'foosecret', 'fookey', $options, $logger); $service = new TokenBasedRememberMeServices(array($userProvider), 'foosecret', 'fookey', $options, $logger);
return $service; return $service;

View File

@ -0,0 +1,63 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Security\Tests;
use Symfony\Component\Finder\Finder;
class TranslationSyncStatusTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getTranslationDirectoriesData
*/
public function testTranslationFileIsNotMissingInCore($dir1, $dir2)
{
$finder = new Finder();
$files = $finder->in($dir1)->files();
foreach ($files as $file) {
$this->assertFileExists($dir2.'/'.$file->getFilename(), 'Missing file '.$file->getFilename().' in directory '.$dir2);
}
}
public function getTranslationDirectoriesData()
{
$legacyTranslationsDir = $this->getLegacyTranslationsDirectory();
$coreTranslationsDir = $this->getCoreTranslationsDirectory();
return array(
'file-not-missing-in-core' => array($legacyTranslationsDir, $coreTranslationsDir),
'file-not-added-in-core' => array($coreTranslationsDir, $legacyTranslationsDir),
);
}
public function testFileContentsAreEqual()
{
$finder = new Finder();
$files = $finder->in($this->getLegacyTranslationsDirectory())->files();
foreach ($files as $file) {
$coreFile = $this->getCoreTranslationsDirectory().'/'.$file->getFilename();
$this->assertFileEquals($file->getRealPath(), $coreFile, $file.' and '.$coreFile.' have equal content.');
}
}
private function getLegacyTranslationsDirectory()
{
return __DIR__.'/../Resources/translations';
}
private function getCoreTranslationsDirectory()
{
return __DIR__.'/../Core/Resources/translations';
}
}

View File

@ -30,6 +30,7 @@
"symfony/security-http": "self.version" "symfony/security-http": "self.version"
}, },
"require-dev": { "require-dev": {
"symfony/finder": "~2.3|~3.0.0",
"symfony/phpunit-bridge": "~2.7|~3.0.0", "symfony/phpunit-bridge": "~2.7|~3.0.0",
"symfony/intl": "~2.3|~3.0.0", "symfony/intl": "~2.3|~3.0.0",
"symfony/routing": "~2.2|~3.0.0", "symfony/routing": "~2.2|~3.0.0",

View File

@ -12,6 +12,7 @@
<testsuites> <testsuites>
<testsuite name="Symfony Security Component Test Suite"> <testsuite name="Symfony Security Component Test Suite">
<directory>./Tests/</directory>
<directory>./Acl/Tests/</directory> <directory>./Acl/Tests/</directory>
<directory>./Core/Tests/</directory> <directory>./Core/Tests/</directory>
<directory>./Http/Tests/</directory> <directory>./Http/Tests/</directory>
@ -24,6 +25,7 @@
<directory>./</directory> <directory>./</directory>
<exclude> <exclude>
<directory>./vendor</directory> <directory>./vendor</directory>
<directory>./Tests</directory>
<directory>./Acl/Tests</directory> <directory>./Acl/Tests</directory>
<directory>./Core/Tests</directory> <directory>./Core/Tests</directory>
<directory>./Http/Tests</directory> <directory>./Http/Tests</directory>

View File

@ -105,7 +105,7 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
/** /**
* Set normalization callbacks. * Set normalization callbacks.
* *
* @param array $callbacks help normalize the result * @param callable[] $callbacks help normalize the result
* *
* @return self * @return self
* *

View File

@ -350,8 +350,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
/** /**
* Adds an escaper for the given context. * Adds an escaper for the given context.
* *
* @param string $context The escaper context (html, js, ...) * @param string $context The escaper context (html, js, ...)
* @param mixed $escaper A PHP callable * @param callable $escaper A PHP callable
*/ */
public function setEscaper($context, $escaper) public function setEscaper($context, $escaper)
{ {
@ -364,7 +364,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
* *
* @param string $context The context name * @param string $context The context name
* *
* @return mixed $escaper A PHP callable * @return callable $escaper A PHP callable
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */

View File

@ -189,8 +189,8 @@ class PluralizationRules
/** /**
* Overrides the default plural rule for a given locale. * Overrides the default plural rule for a given locale.
* *
* @param string $rule A PHP callable * @param callable $rule A PHP callable
* @param string $locale The locale * @param string $locale The locale
* *
* @throws \LogicException * @throws \LogicException
*/ */