Merge branch '2.3' into 2.6
* 2.3:
Added 'default' color
[HttpFoundation] Reload the session after regenerating its id
[HttpFoundation] Add a test case to confirm a bug in session migration
[Finder] Command::addAtIndex() fails with Command instance argument
[DependencyInjection] Freeze also FrozenParameterBag::remove
fix CS
fixed CS
Add a way to reset the singleton
[Security] allow to use `method` in XML configs
Remove var not used due to returning early (introduced in 8982c32
)
Enhance hhvm test skip message
This commit is contained in:
commit
e6cc4918bf
@ -91,7 +91,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
|
||||
'utf8' => 'foo',
|
||||
array(
|
||||
'nonutf8' => DbalLogger::BINARY_DATA_VALUE,
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
;
|
||||
@ -100,7 +100,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
|
||||
'utf8' => 'foo',
|
||||
array(
|
||||
'nonutf8' => "\x7F\xFF",
|
||||
)
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -162,6 +162,7 @@ class MainConfiguration implements ConfigurationInterface
|
||||
->cannotBeOverwritten()
|
||||
->prototype('array')
|
||||
->fixXmlConfig('ip')
|
||||
->fixXmlConfig('method')
|
||||
->children()
|
||||
->scalarNode('requires_channel')->defaultNull()->end()
|
||||
->scalarNode('path')
|
||||
|
@ -82,7 +82,6 @@ class Cookie
|
||||
|
||||
$this->expires = $timestampAsDateTime->getTimestamp();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,6 +29,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
'magenta' => array('set' => 35, 'unset' => 39),
|
||||
'cyan' => array('set' => 36, 'unset' => 39),
|
||||
'white' => array('set' => 37, 'unset' => 39),
|
||||
'default' => array('set' => 39, 'unset' => 39),
|
||||
);
|
||||
private static $availableBackgroundColors = array(
|
||||
'black' => array('set' => 40, 'unset' => 49),
|
||||
@ -39,6 +40,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
'magenta' => array('set' => 45, 'unset' => 49),
|
||||
'cyan' => array('set' => 46, 'unset' => 49),
|
||||
'white' => array('set' => 47, 'unset' => 49),
|
||||
'default' => array('set' => 49, 'unset' => 49),
|
||||
);
|
||||
private static $availableOptions = array(
|
||||
'bold' => array('set' => 1, 'unset' => 22),
|
||||
|
@ -20,7 +20,7 @@ namespace Symfony\Component\Console\Helper;
|
||||
*/
|
||||
class DebugFormatterHelper extends Helper
|
||||
{
|
||||
private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white');
|
||||
private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
|
||||
private $started = array();
|
||||
private $count = -1;
|
||||
|
||||
|
@ -37,6 +37,9 @@ class OutputFormatterStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$style->setForeground('blue');
|
||||
$this->assertEquals("\033[34mfoo\033[39m", $style->apply('foo'));
|
||||
|
||||
$style->setForeground('default');
|
||||
$this->assertEquals("\033[39mfoo\033[39m", $style->apply('foo'));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$style->setForeground('undefined-color');
|
||||
}
|
||||
@ -51,6 +54,9 @@ class OutputFormatterStyleTest extends \PHPUnit_Framework_TestCase
|
||||
$style->setBackground('yellow');
|
||||
$this->assertEquals("\033[43mfoo\033[49m", $style->apply('foo'));
|
||||
|
||||
$style->setBackground('default');
|
||||
$this->assertEquals("\033[49mfoo\033[49m", $style->apply('foo'));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$style->setBackground('undefined-color');
|
||||
}
|
||||
|
@ -856,8 +856,8 @@ EOF;
|
||||
|
||||
if (count($scopes = $this->container->getScopes()) > 0) {
|
||||
$code .= "\n";
|
||||
$code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n";
|
||||
$code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n";
|
||||
$code .= ' $this->scopes = '.$this->dumpValue($scopes).";\n";
|
||||
$code .= ' $this->scopeChildren = '.$this->dumpValue($this->container->getScopeChildren()).";\n";
|
||||
}
|
||||
|
||||
$code .= $this->addMethodMap();
|
||||
@ -902,8 +902,8 @@ EOF;
|
||||
|
||||
$code .= "\n";
|
||||
if (count($scopes = $this->container->getScopes()) > 0) {
|
||||
$code .= " \$this->scopes = ".$this->dumpValue($scopes).";\n";
|
||||
$code .= " \$this->scopeChildren = ".$this->dumpValue($this->container->getScopeChildren()).";\n";
|
||||
$code .= ' $this->scopes = '.$this->dumpValue($scopes).";\n";
|
||||
$code .= ' $this->scopeChildren = '.$this->dumpValue($this->container->getScopeChildren()).";\n";
|
||||
} else {
|
||||
$code .= " \$this->scopes = array();\n";
|
||||
$code .= " \$this->scopeChildren = array();\n";
|
||||
|
@ -69,4 +69,14 @@ class FrozenParameterBag extends ParameterBag
|
||||
{
|
||||
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function remove($name)
|
||||
{
|
||||
throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');
|
||||
}
|
||||
}
|
||||
|
@ -825,7 +825,6 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testFormRegistrySetArrayOnNotCompoundField()
|
||||
{
|
||||
|
||||
$registry = new FormFieldRegistry();
|
||||
$registry->add($this->getFormFieldMock('bar'));
|
||||
|
||||
|
@ -287,7 +287,7 @@ class Command
|
||||
*/
|
||||
public function addAtIndex($bit, $index)
|
||||
{
|
||||
array_splice($this->bits, $index, 0, $bit);
|
||||
array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
162
src/Symfony/Component/Finder/Tests/Shell/CommandTest.php
Normal file
162
src/Symfony/Component/Finder/Tests/Shell/CommandTest.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?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\Finder\Tests\Shell;
|
||||
|
||||
use Symfony\Component\Finder\Shell\Command;
|
||||
|
||||
class CommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$this->assertInstanceOf('Symfony\Component\Finder\Shell\Command', Command::create());
|
||||
}
|
||||
|
||||
public function testAdd()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
$this->assertSame('--force', $cmd->join());
|
||||
}
|
||||
|
||||
public function testAddAsFirst()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
|
||||
$cmd->addAtIndex(Command::create()->add('-F'), 0);
|
||||
$this->assertSame('-F --force', $cmd->join());
|
||||
}
|
||||
|
||||
public function testAddAsLast()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
|
||||
$cmd->addAtIndex(Command::create()->add('-F'), 1);
|
||||
$this->assertSame('--force -F', $cmd->join());
|
||||
}
|
||||
|
||||
public function testAddInBetween()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
$cmd->addAtIndex(Command::create()->add('-F'), 0);
|
||||
|
||||
$cmd->addAtIndex(Command::create()->add('-X'), 1);
|
||||
$this->assertSame('-F -X --force', $cmd->join());
|
||||
}
|
||||
|
||||
public function testCount()
|
||||
{
|
||||
$cmd = Command::create();
|
||||
$this->assertSame(0, $cmd->length());
|
||||
|
||||
$cmd->add('--force');
|
||||
$this->assertSame(1, $cmd->length());
|
||||
|
||||
$cmd->add('--run');
|
||||
$this->assertSame(2, $cmd->length());
|
||||
}
|
||||
|
||||
public function testTop()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
|
||||
$cmd->top('--run');
|
||||
$this->assertSame('--run --force', $cmd->join());
|
||||
}
|
||||
|
||||
public function testTopLabeled()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
|
||||
$cmd->top('--run');
|
||||
$cmd->ins('--something');
|
||||
$cmd->top('--something');
|
||||
$this->assertSame('--something --run --force ', $cmd->join());
|
||||
}
|
||||
|
||||
public function testArg()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
|
||||
$cmd->arg('--run');
|
||||
$this->assertSame('--force \'--run\'', $cmd->join());
|
||||
}
|
||||
|
||||
public function testCmd()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
|
||||
$cmd->cmd('run');
|
||||
$this->assertSame('--force run', $cmd->join());
|
||||
}
|
||||
|
||||
public function testInsDuplicateLabelException()
|
||||
{
|
||||
$cmd = Command::create()->add('--force');
|
||||
|
||||
$cmd->ins('label');
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$cmd->ins('label');
|
||||
}
|
||||
|
||||
public function testEnd()
|
||||
{
|
||||
$parent = Command::create();
|
||||
$cmd = Command::create($parent);
|
||||
|
||||
$this->assertSame($parent, $cmd->end());
|
||||
}
|
||||
|
||||
public function testEndNoParentException()
|
||||
{
|
||||
$cmd = Command::create();
|
||||
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$cmd->end();
|
||||
}
|
||||
|
||||
public function testGetMissingLabelException()
|
||||
{
|
||||
$cmd = Command::create();
|
||||
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$cmd->get('invalid');
|
||||
}
|
||||
|
||||
public function testErrorHandler()
|
||||
{
|
||||
$cmd = Command::create();
|
||||
$handler = function() { return 'error-handler'; };
|
||||
$cmd->setErrorHandler($handler);
|
||||
|
||||
$this->assertSame($handler, $cmd->getErrorHandler());
|
||||
}
|
||||
|
||||
public function testExecute()
|
||||
{
|
||||
$cmd = Command::create();
|
||||
$cmd->add('php');
|
||||
$cmd->add('--version');
|
||||
$result = $cmd->execute();
|
||||
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertRegexp('/PHP|HipHop/', $result[0]);
|
||||
}
|
||||
|
||||
public function testCastToString()
|
||||
{
|
||||
$cmd = Command::create();
|
||||
$cmd->add('--force');
|
||||
$cmd->add('--run');
|
||||
|
||||
$this->assertSame('--force --run', (string) $cmd);
|
||||
}
|
||||
}
|
@ -38,9 +38,9 @@ class PreloadedExtension implements FormExtensionInterface
|
||||
/**
|
||||
* Creates a new preloaded extension.
|
||||
*
|
||||
* @param FormTypeInterface[] $types The types that the extension should support.
|
||||
* @param array[FormTypeExtensionInterface[]] typeExtensions The type extensions that the extension should support.
|
||||
* @param FormTypeGuesserInterface|null $typeGuesser The guesser that the extension should support.
|
||||
* @param FormTypeInterface[] $types The types that the extension should support.
|
||||
* @param array[FormTypeExtensionInterface[]] $typeExtensions The type extensions that the extension should support.
|
||||
* @param FormTypeGuesserInterface|null $typeGuesser The guesser that the extension should support.
|
||||
*/
|
||||
public function __construct(array $types, array $typeExtensions, FormTypeGuesserInterface $typeGuesser = null)
|
||||
{
|
||||
|
@ -67,6 +67,14 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the singleton instance.
|
||||
*/
|
||||
public static function reset()
|
||||
{
|
||||
self::$instance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all natively provided mime type guessers.
|
||||
*/
|
||||
|
@ -510,7 +510,6 @@ class Request
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$content = '';
|
||||
try {
|
||||
$content = $this->getContent();
|
||||
} catch (\LogicException $e) {
|
||||
|
@ -203,7 +203,13 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
$this->metadataBag->stampNew();
|
||||
}
|
||||
|
||||
return session_regenerate_id($destroy);
|
||||
$isRegenerated = session_regenerate_id($destroy);
|
||||
|
||||
// The reference to $_SESSION in session bags is lost in PHP7 and we need to re-create it.
|
||||
// @see https://bugs.php.net/bug.php?id=70013
|
||||
$this->loadSession();
|
||||
|
||||
return $isRegenerated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,19 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('gif', $file->guessExtension());
|
||||
}
|
||||
|
||||
public function testGuessExtensionWithReset()
|
||||
{
|
||||
$file = new File(__DIR__.'/Fixtures/other-file.example');
|
||||
$guesser = $this->createMockGuesser($file->getPathname(), 'image/gif');
|
||||
MimeTypeGuesser::getInstance()->register($guesser);
|
||||
|
||||
$this->assertEquals('gif', $file->guessExtension());
|
||||
|
||||
MimeTypeGuesser::reset();
|
||||
|
||||
$this->assertNull($file->guessExtension());
|
||||
}
|
||||
|
||||
public function testConstructWhenFileNotExists()
|
||||
{
|
||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||
|
@ -940,7 +940,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @dataProvider getContentCantBeCalledTwiceWithResourcesProvider
|
||||
*/
|
||||
public function testGetContentCanBeCalledTwiceWithResources($first, $second)
|
||||
|
@ -119,6 +119,17 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(11, $storage->getBag('attributes')->get('legs'));
|
||||
}
|
||||
|
||||
public function testSessionGlobalIsUpToDateAfterIdRegeneration()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
$storage->start();
|
||||
$storage->getBag('attributes')->set('lucky', 7);
|
||||
$storage->regenerate();
|
||||
$storage->getBag('attributes')->set('lucky', 42);
|
||||
|
||||
$this->assertEquals(42, $_SESSION['_sf2_attributes']['lucky']);
|
||||
}
|
||||
|
||||
public function testDefaultSessionCacheLimiter()
|
||||
{
|
||||
$this->iniSet('session.cache_limiter', 'nocache');
|
||||
|
@ -34,7 +34,6 @@ class FragmentListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($request->query->has('_path'));
|
||||
}
|
||||
|
||||
|
||||
public function testOnlyTriggeredIfControllerWasNotDefinedYet()
|
||||
{
|
||||
$request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo');
|
||||
|
@ -232,11 +232,11 @@ EOF;
|
||||
$conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
|
||||
$hasTrailingSlash = true;
|
||||
} else {
|
||||
$conditions[] = sprintf("\$pathinfo === %s", var_export(str_replace('\\', '', $m['url']), true));
|
||||
$conditions[] = sprintf('$pathinfo === %s', var_export(str_replace('\\', '', $m['url']), true));
|
||||
}
|
||||
} else {
|
||||
if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) {
|
||||
$conditions[] = sprintf("0 === strpos(\$pathinfo, %s)", var_export($compiledRoute->getStaticPrefix(), true));
|
||||
$conditions[] = sprintf('0 === strpos($pathinfo, %s)', var_export($compiledRoute->getStaticPrefix(), true));
|
||||
}
|
||||
|
||||
$regex = $compiledRoute->getRegex();
|
||||
@ -244,7 +244,7 @@ EOF;
|
||||
$regex = substr($regex, 0, $pos).'/?$'.substr($regex, $pos + 2);
|
||||
$hasTrailingSlash = true;
|
||||
}
|
||||
$conditions[] = sprintf("preg_match(%s, \$pathinfo, \$matches)", var_export($regex, true));
|
||||
$conditions[] = sprintf('preg_match(%s, $pathinfo, $matches)', var_export($regex, true));
|
||||
|
||||
$matches = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user