Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicolas-grekas committed Oct 6, 2015
2 parents a1c7af1 + 380e2ba commit 7236571
Show file tree
Hide file tree
Showing 22 changed files with 157 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Command/DebugCommand.php
Expand Up @@ -149,7 +149,7 @@ private function getMetadata($type, $entity)
return;
}
$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');
} elseif (function_exists($cb)) {
$refl = new \ReflectionFunction($cb);
Expand Down
Expand Up @@ -14,7 +14,7 @@
<service id="debug.debug_handlers_listener" class="%debug.debug_handlers_listener.class%">
<tag name="kernel.event_subscriber" />
<tag name="monolog.logger" channel="php" />
<argument /><!-- Exception handler -->
<argument>null</argument><!-- Exception handler -->
<argument type="service" id="logger" on-invalid="null" />
<argument>null</argument><!-- Log levels map for enabled error levels -->
<argument>null</argument>
Expand Down
Expand Up @@ -137,15 +137,17 @@ private function inspectApplication()
private function sortCommands(array $commands)
{
$namespacedCommands = array();
$globalCommands = array();
foreach ($commands as $name => $command) {
$key = $this->application->extractNamespace($name, 1);
if (!$key) {
$key = '_global';
$globalCommands['_global'][$name] = $command;
} else {
$namespacedCommands[$key][$name] = $command;
}

$namespacedCommands[$key][$name] = $command;
}
ksort($namespacedCommands);
$namespacedCommands = array_merge($globalCommands, $namespacedCommands);

foreach ($namespacedCommands as &$commandsSet) {
ksort($commandsSet);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Question/Question.php
Expand Up @@ -220,7 +220,7 @@ public function getMaxAttempts()
*
* 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
*/
Expand All @@ -236,7 +236,7 @@ public function setNormalizer($normalizer)
*
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
*
* @return string|\Closure
* @return callable
*/
public function getNormalizer()
{
Expand Down
48 changes: 48 additions & 0 deletions src/Symfony/Component/Console/Tests/Command/ListCommandTest.php
Expand Up @@ -61,4 +61,52 @@ public function testExecuteListsCommandsWithNamespaceArgument()

$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)));
}
}
12 changes: 12 additions & 0 deletions src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php
@@ -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');
}
}
Expand Up @@ -26,8 +26,8 @@ class CustomFilterIterator extends FilterIterator
/**
* Constructor.
*
* @param \Iterator $iterator The Iterator to filter
* @param array $filters An array of PHP callbacks
* @param \Iterator $iterator The Iterator to filter
* @param callable[] $filters An array of PHP callbacks
*
* @throws \InvalidArgumentException
*/
Expand Down
Expand Up @@ -131,7 +131,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete
*
* @param string $controller A Controller string
*
* @return mixed A PHP callable
* @return callable A PHP callable
*
* @throws \InvalidArgumentException
*/
Expand Down
Expand Up @@ -29,8 +29,6 @@ class FilterControllerEvent extends KernelEvent
{
/**
* The current controller.
*
* @var callable
*/
private $controller;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/Process.php
Expand Up @@ -1270,7 +1270,7 @@ private function getDescriptors()
*
* @param callable|null $callback The user defined PHP callback
*
* @return callable A PHP callable
* @return \Closure A PHP closure
*/
protected function buildCallback($callback)
{
Expand Down
Expand Up @@ -8,15 +8,15 @@
</trans-unit>
<trans-unit id="2">
<source>Authentication credentials could not be found.</source>
<target>Yetkilendirme girdileri bulunamadı.</target>
<target>Kimlik bilgileri bulunamadı.</target>
</trans-unit>
<trans-unit id="3">
<source>Authentication request could not be processed due to a system problem.</source>
<target>Bir sistem hatası nedeniyle yetkilendirme isteği işleme alınamıyor.</target>
</trans-unit>
<trans-unit id="4">
<source>Invalid credentials.</source>
<target>Geçersiz girdiler.</target>
<target>Geçersiz kimlik bilgileri.</target>
</trans-unit>
<trans-unit id="5">
<source>Cookie has already been used by someone else.</source>
Expand All @@ -32,7 +32,7 @@
</trans-unit>
<trans-unit id="8">
<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 id="9">
<source>No authentication provider found to support the authentication token.</source>
Expand All @@ -44,7 +44,7 @@
</trans-unit>
<trans-unit id="11">
<source>No token could be found.</source>
<target>Bilet bulunamadı.</target>
<target>Fiş bulunamadı.</target>
</trans-unit>
<trans-unit id="12">
<source>Username could not be found.</source>
Expand All @@ -56,11 +56,11 @@
</trans-unit>
<trans-unit id="14">
<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 id="15">
<source>Account is disabled.</source>
<target>Hesap devre dışı bırakılmış.</target>
<target>Hesap engellenmiş.</target>
</trans-unit>
<trans-unit id="16">
<source>Account is locked.</source>
Expand Down
Expand Up @@ -102,7 +102,7 @@ public function getStrategiesWith2RolesTests()
protected function getVoterFor2Roles($token, $vote1, $vote2)
{
$voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
$voter->expects($this->exactly(2))
$voter->expects($this->any())
->method('vote')
->will($this->returnValueMap(array(
array($token, null, array('ROLE_FOO'), $vote1),
Expand Down
Expand Up @@ -35,7 +35,10 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
const COOKIE_DELIMITER = ':';

protected $logger;
protected $options;
protected $options = array(
'secure' => false,
'httponly' => true,
);
private $providerKey;
private $secret;
private $userProviders;
Expand Down Expand Up @@ -66,7 +69,7 @@ public function __construct(array $userProviders, $secret, $providerKey, array $
$this->userProviders = $userProviders;
$this->secret = $secret;
$this->providerKey = $providerKey;
$this->options = $options;
$this->options = array_merge($this->options, $options);
$this->logger = $logger;
}

Expand Down
Expand Up @@ -91,11 +91,8 @@ public function testLogout(array $options)
$request = new Request();
$response = new Response();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');

$service->logout($request, $response, $token);

$cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME);

$this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie);
$this->assertTrue($cookie->isCleared());
$this->assertSame($options['name'], $cookie->getName());
Expand Down Expand Up @@ -286,13 +283,6 @@ protected function getService($userProvider = null, $options = array(), $logger
$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(
array($userProvider), 'foosecret', 'fookey', $options, $logger,
));
Expand Down
Expand Up @@ -313,13 +313,6 @@ protected function getService($userProvider = null, $options = array(), $logger
$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'));
}

Expand Down
Expand Up @@ -266,13 +266,6 @@ protected function getService($userProvider = null, $options = array(), $logger
$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);

return $service;
Expand Down
63 changes: 63 additions & 0 deletions src/Symfony/Component/Security/Tests/TranslationSyncStatusTest.php
@@ -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';
}
}
1 change: 1 addition & 0 deletions src/Symfony/Component/Security/composer.json
Expand Up @@ -30,6 +30,7 @@
"symfony/security-http": "self.version"
},
"require-dev": {
"symfony/finder": "~2.3|~3.0.0",
"symfony/phpunit-bridge": "~2.7|~3.0.0",
"symfony/intl": "~2.3|~3.0.0",
"symfony/routing": "~2.2|~3.0.0",
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Security/phpunit.xml.dist
Expand Up @@ -12,6 +12,7 @@

<testsuites>
<testsuite name="Symfony Security Component Test Suite">
<directory>./Tests/</directory>
<directory>./Acl/Tests/</directory>
<directory>./Core/Tests/</directory>
<directory>./Http/Tests/</directory>
Expand All @@ -24,6 +25,7 @@
<directory>./</directory>
<exclude>
<directory>./vendor</directory>
<directory>./Tests</directory>
<directory>./Acl/Tests</directory>
<directory>./Core/Tests</directory>
<directory>./Http/Tests</directory>
Expand Down
Expand Up @@ -105,7 +105,7 @@ public function setCircularReferenceHandler($circularReferenceHandler)
/**
* Set normalization callbacks.
*
* @param array $callbacks help normalize the result
* @param callable[] $callbacks help normalize the result
*
* @return self
*
Expand Down

0 comments on commit 7236571

Please sign in to comment.