Merge branch '2.7' into 2.8
* 2.7:
Added 'default' color
[HttpFoundation] Reload the session after regenerating its id
[HttpFoundation] Add a test case to confirm a bug in session migration
[Serializer] Fix ClassMetadata::sleep()
[2.6] Static Code Analysis for Components and Bundles
[Finder] Command::addAtIndex() fails with Command instance argument
[DependencyInjection] Freeze also FrozenParameterBag::remove
[Twig][Bridge] replaced `extends` with `use` in bootstrap_3_horizontal_layout.html.twig
fix CS
fixed CS
Add a way to reset the singleton
[Security] allow to use `method` in XML configs
[Serializer] Fix Groups tests.
Remove duplicate example
Remove var not used due to returning early (introduced in 8982c32
)
[Serializer] Fix Groups PHPDoc
Enhance hhvm test skip message
fix for legacy asset() with EmptyVersionStrategy
[Form] Added upgrade notes for #15061
This commit is contained in:
commit
f5fefeff49
@ -665,3 +665,57 @@ Security
|
|||||||
* `SwitchUserListener`
|
* `SwitchUserListener`
|
||||||
* `AccessListener`
|
* `AccessListener`
|
||||||
* `RememberMeListener`
|
* `RememberMeListener`
|
||||||
|
|
||||||
|
UPGRADE FROM 2.7.1 to 2.7.2
|
||||||
|
===========================
|
||||||
|
|
||||||
|
Form
|
||||||
|
----
|
||||||
|
|
||||||
|
* In order to fix a few regressions in the new `ChoiceList` implementation,
|
||||||
|
a few details had to be changed compared to 2.7.
|
||||||
|
|
||||||
|
The legacy `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface`
|
||||||
|
now does not extend the new `Symfony\Component\Form\ChoiceList\ChoiceListInterface`
|
||||||
|
anymore. If you pass an implementation of the old interface in a context
|
||||||
|
where the new interface is required, wrap the list into a
|
||||||
|
`LegacyChoiceListAdapter`:
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||||
|
|
||||||
|
function doSomething(ChoiceListInterface $choiceList)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
doSomething($legacyList);
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||||
|
use Symfony\Component\Form\ChoiceList\LegacyChoiceListAdapter;
|
||||||
|
|
||||||
|
function doSomething(ChoiceListInterface $choiceList)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
doSomething(new LegacyChoiceListAdapter($legacyList));
|
||||||
|
```
|
||||||
|
|
||||||
|
The new `ChoiceListInterface` now has two additional methods
|
||||||
|
`getStructuredValues()` and `getOriginalKeys()`. You should add these methods
|
||||||
|
if you implement this interface. See their doc blocks and the implementation
|
||||||
|
of the core choice lists for inspiration.
|
||||||
|
|
||||||
|
The method `ArrayKeyChoiceList::toArrayKey()` was marked as internal. This
|
||||||
|
method was never supposed to be used outside the class.
|
||||||
|
|
||||||
|
The method `ChoiceListFactoryInterface::createView()` does not accept arrays
|
||||||
|
and `Traversable` instances anymore for the `$groupBy` parameter. Pass a
|
||||||
|
callable instead.
|
||||||
|
@ -300,10 +300,6 @@ UPGRADE FROM 2.x to 3.0
|
|||||||
echo $form->getErrors(true, false);
|
echo $form->getErrors(true, false);
|
||||||
```
|
```
|
||||||
|
|
||||||
```php
|
|
||||||
echo $form->getErrors(true, false);
|
|
||||||
```
|
|
||||||
|
|
||||||
### FrameworkBundle
|
### FrameworkBundle
|
||||||
|
|
||||||
* The `config:debug`, `container:debug`, `router:debug`, `translation:debug`
|
* The `config:debug`, `container:debug`, `router:debug`, `translation:debug`
|
||||||
|
@ -91,7 +91,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
|
|||||||
'utf8' => 'foo',
|
'utf8' => 'foo',
|
||||||
array(
|
array(
|
||||||
'nonutf8' => DbalLogger::BINARY_DATA_VALUE,
|
'nonutf8' => DbalLogger::BINARY_DATA_VALUE,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
@ -100,7 +100,7 @@ class DbalLoggerTest extends \PHPUnit_Framework_TestCase
|
|||||||
'utf8' => 'foo',
|
'utf8' => 'foo',
|
||||||
array(
|
array(
|
||||||
'nonutf8' => "\x7F\xFF",
|
'nonutf8' => "\x7F\xFF",
|
||||||
)
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,11 +108,15 @@ class AssetExtension extends \Twig_Extension
|
|||||||
$v->setAccessible(true);
|
$v->setAccessible(true);
|
||||||
$currentVersionStrategy = $v->getValue($package);
|
$currentVersionStrategy = $v->getValue($package);
|
||||||
|
|
||||||
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
|
if (property_exists($currentVersionStrategy, 'format')) {
|
||||||
$f->setAccessible(true);
|
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
|
||||||
$format = $f->getValue($currentVersionStrategy);
|
$f->setAccessible(true);
|
||||||
|
$format = $f->getValue($currentVersionStrategy);
|
||||||
|
|
||||||
$v->setValue($package, new StaticVersionStrategy($version, $format));
|
$v->setValue($package, new StaticVersionStrategy($version, $format));
|
||||||
|
} else {
|
||||||
|
$v->setValue($package, new StaticVersionStrategy($version));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% extends "bootstrap_3_layout.html.twig" %}
|
{% use "bootstrap_3_layout.html.twig" %}
|
||||||
|
|
||||||
{% block form_start -%}
|
{% block form_start -%}
|
||||||
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %}
|
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %}
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Bridge\Twig\Extension\AssetExtension;
|
|||||||
use Symfony\Component\Asset\Package;
|
use Symfony\Component\Asset\Package;
|
||||||
use Symfony\Component\Asset\Packages;
|
use Symfony\Component\Asset\Packages;
|
||||||
use Symfony\Component\Asset\PathPackage;
|
use Symfony\Component\Asset\PathPackage;
|
||||||
|
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
|
||||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||||
|
|
||||||
class AssetExtensionTest extends \PHPUnit_Framework_TestCase
|
class AssetExtensionTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -41,6 +42,16 @@ class AssetExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('/foo/me.png?version=42', $extension->getAssetUrl('me.png', null, false, 42));
|
$this->assertEquals('/foo/me.png?version=42', $extension->getAssetUrl('me.png', null, false, 42));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
|
public function testGetAssetUrlWithEmptyVersionStrategy()
|
||||||
|
{
|
||||||
|
$extension = $this->createExtension(new PathPackage('foo', new EmptyVersionStrategy()));
|
||||||
|
|
||||||
|
$this->assertEquals('/foo/me.png?42', $extension->getAssetUrl('me.png', null, false, 42));
|
||||||
|
}
|
||||||
|
|
||||||
private function createExtension(Package $package)
|
private function createExtension(Package $package)
|
||||||
{
|
{
|
||||||
$foundationExtension = $this->getMockBuilder('Symfony\Bridge\Twig\Extension\HttpFoundationExtension')->disableOriginalConstructor()->getMock();
|
$foundationExtension = $this->getMockBuilder('Symfony\Bridge\Twig\Extension\HttpFoundationExtension')->disableOriginalConstructor()->getMock();
|
||||||
|
@ -121,7 +121,7 @@ EOF
|
|||||||
$extractor = $this->getContainer()->get('translation.extractor');
|
$extractor = $this->getContainer()->get('translation.extractor');
|
||||||
$extractor->setPrefix($input->getOption('prefix'));
|
$extractor->setPrefix($input->getOption('prefix'));
|
||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path = $path.'views';
|
$path .= 'views';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$extractor->extract($path, $extractedCatalogue);
|
$extractor->extract($path, $extractedCatalogue);
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ EOF
|
|||||||
$output->text('Loading translation files');
|
$output->text('Loading translation files');
|
||||||
$loader = $this->getContainer()->get('translation.loader');
|
$loader = $this->getContainer()->get('translation.loader');
|
||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path = $path.'translations';
|
$path .= 'translations';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$loader->loadMessages($path, $currentCatalogue);
|
$loader->loadMessages($path, $currentCatalogue);
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ EOF
|
|||||||
|
|
||||||
$bundleTransPath = false;
|
$bundleTransPath = false;
|
||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path = $path.'translations';
|
$path .= 'translations';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$bundleTransPath = $path;
|
$bundleTransPath = $path;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ class TextDescriptor extends Descriptor
|
|||||||
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');
|
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');
|
||||||
|
|
||||||
if ($definition->getFile()) {
|
if ($definition->getFile()) {
|
||||||
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
|
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ?: '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($definition->getFactoryClass(false)) {
|
if ($definition->getFactoryClass(false)) {
|
||||||
|
@ -670,22 +670,22 @@ class FrameworkExtension extends Extension
|
|||||||
if (class_exists('Symfony\Component\Validator\Validation')) {
|
if (class_exists('Symfony\Component\Validator\Validation')) {
|
||||||
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
|
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
|
||||||
|
|
||||||
$dirs[] = dirname($r->getFilename()).'/Resources/translations';
|
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
|
||||||
}
|
}
|
||||||
if (class_exists('Symfony\Component\Form\Form')) {
|
if (class_exists('Symfony\Component\Form\Form')) {
|
||||||
$r = new \ReflectionClass('Symfony\Component\Form\Form');
|
$r = new \ReflectionClass('Symfony\Component\Form\Form');
|
||||||
|
|
||||||
$dirs[] = dirname($r->getFilename()).'/Resources/translations';
|
$dirs[] = dirname($r->getFileName()).'/Resources/translations';
|
||||||
}
|
}
|
||||||
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
|
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
|
||||||
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
|
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
|
||||||
|
|
||||||
$dirs[] = dirname($r->getFilename()).'/../Resources/translations';
|
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
|
||||||
}
|
}
|
||||||
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
|
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
|
||||||
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
|
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
|
||||||
$reflection = new \ReflectionClass($class);
|
$reflection = new \ReflectionClass($class);
|
||||||
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/translations')) {
|
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
|
||||||
$dirs[] = $dir;
|
$dirs[] = $dir;
|
||||||
}
|
}
|
||||||
if (is_dir($dir = sprintf($overridePath, $bundle))) {
|
if (is_dir($dir = sprintf($overridePath, $bundle))) {
|
||||||
@ -807,7 +807,7 @@ class FrameworkExtension extends Extension
|
|||||||
$bundles = $container->getParameter('kernel.bundles');
|
$bundles = $container->getParameter('kernel.bundles');
|
||||||
foreach ($bundles as $bundle) {
|
foreach ($bundles as $bundle) {
|
||||||
$reflection = new \ReflectionClass($bundle);
|
$reflection = new \ReflectionClass($bundle);
|
||||||
$dirname = dirname($reflection->getFilename());
|
$dirname = dirname($reflection->getFileName());
|
||||||
|
|
||||||
if (is_file($file = $dirname.'/Resources/config/validation.xml')) {
|
if (is_file($file = $dirname.'/Resources/config/validation.xml')) {
|
||||||
$files[0][] = realpath($file);
|
$files[0][] = realpath($file);
|
||||||
@ -827,7 +827,15 @@ class FrameworkExtension extends Extension
|
|||||||
$files[1][] = $file->getRealpath();
|
$files[1][] = $file->getRealpath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
$container->addResource(new DirectoryResource($dir));
|
$container->addResource(new DirectoryResource($dir));
|
||||||
|
=======
|
||||||
|
foreach ($container->getParameter('kernel.bundles') as $bundle) {
|
||||||
|
$reflection = new \ReflectionClass($bundle);
|
||||||
|
if (is_file($file = dirname($reflection->getFileName()).'/Resources/config/validation.yml')) {
|
||||||
|
$files[] = realpath($file);
|
||||||
|
$container->addResource(new FileResource($file));
|
||||||
|
>>>>>>> 2.6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class CacheClearCommandTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->fs = new Filesystem();
|
$this->fs = new Filesystem();
|
||||||
$this->kernel = new TestAppKernel('test', true);
|
$this->kernel = new TestAppKernel('test', true);
|
||||||
$this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_');
|
$this->rootDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('sf2_cache_', true);
|
||||||
$this->kernel->setRootDir($this->rootDir);
|
$this->kernel->setRootDir($this->rootDir);
|
||||||
$this->fs->mkdir($this->rootDir);
|
$this->fs->mkdir($this->rootDir);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ class TranslationDebugCommandTest extends \PHPUnit_Framework_TestCase
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->fs = new Filesystem();
|
$this->fs = new Filesystem();
|
||||||
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation');
|
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true);
|
||||||
$this->fs->mkdir($this->translationDir.'/Resources/translations');
|
$this->fs->mkdir($this->translationDir.'/Resources/translations');
|
||||||
$this->fs->mkdir($this->translationDir.'/Resources/views');
|
$this->fs->mkdir($this->translationDir.'/Resources/views');
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$data = $this->getDescriptionTestData(ObjectsProvider::getContainerParameter());
|
$data = $this->getDescriptionTestData(ObjectsProvider::getContainerParameter());
|
||||||
|
|
||||||
array_push($data[0], array('parameter' => 'database_name'));
|
$data[0][] = array('parameter' => 'database_name');
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,7 @@ class MainConfiguration implements ConfigurationInterface
|
|||||||
->cannotBeOverwritten()
|
->cannotBeOverwritten()
|
||||||
->prototype('array')
|
->prototype('array')
|
||||||
->fixXmlConfig('ip')
|
->fixXmlConfig('ip')
|
||||||
|
->fixXmlConfig('method')
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('requires_channel')->defaultNull()->end()
|
->scalarNode('requires_channel')->defaultNull()->end()
|
||||||
->scalarNode('path')
|
->scalarNode('path')
|
||||||
@ -300,7 +301,7 @@ class MainConfiguration implements ConfigurationInterface
|
|||||||
})
|
})
|
||||||
->end()
|
->end()
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('secret')->defaultValue(uniqid())->end()
|
->scalarNode('secret')->defaultValue(uniqid('', true))->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->arrayNode('switch_user')
|
->arrayNode('switch_user')
|
||||||
|
@ -54,7 +54,7 @@ class InMemoryFactory implements UserProviderFactoryInterface
|
|||||||
->useAttributeAsKey('name')
|
->useAttributeAsKey('name')
|
||||||
->prototype('array')
|
->prototype('array')
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('password')->defaultValue(uniqid())->end()
|
->scalarNode('password')->defaultValue(uniqid('', true))->end()
|
||||||
->arrayNode('roles')
|
->arrayNode('roles')
|
||||||
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
|
@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists twig functions, filters, globals and tests present in the current project
|
* Lists twig functions, filters, globals and tests present in the current project.
|
||||||
*
|
*
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
|
@ -88,7 +88,7 @@ class TwigExtension extends Extension
|
|||||||
$container->addResource(new FileExistenceResource($dir));
|
$container->addResource(new FileExistenceResource($dir));
|
||||||
|
|
||||||
$reflection = new \ReflectionClass($class);
|
$reflection = new \ReflectionClass($class);
|
||||||
$dir = dirname($reflection->getFilename()).'/Resources/views';
|
$dir = dirname($reflection->getFileName()).'/Resources/views';
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
|
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
|
||||||
}
|
}
|
||||||
|
@ -190,10 +190,8 @@ class TwigExtensionTest extends TestCase
|
|||||||
$def = $container->getDefinition('twig.loader.filesystem');
|
$def = $container->getDefinition('twig.loader.filesystem');
|
||||||
$paths = array();
|
$paths = array();
|
||||||
foreach ($def->getMethodCalls() as $call) {
|
foreach ($def->getMethodCalls() as $call) {
|
||||||
if ('addPath' === $call[0]) {
|
if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) {
|
||||||
if (false === strpos($call[1][0], 'Form')) {
|
$paths[] = $call[1];
|
||||||
$paths[] = $call[1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ class Cookie
|
|||||||
|
|
||||||
$this->expires = $timestampAsDateTime->getTimestamp();
|
$this->expires = $timestampAsDateTime->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,7 +196,7 @@ class XmlUtils
|
|||||||
return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
||||||
case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
|
case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)):
|
||||||
$raw = $value;
|
$raw = $value;
|
||||||
$cast = intval($value);
|
$cast = (int) $value;
|
||||||
|
|
||||||
return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
||||||
case 'true' === $lowercaseValue:
|
case 'true' === $lowercaseValue:
|
||||||
|
@ -29,6 +29,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
|||||||
'magenta' => array('set' => 35, 'unset' => 39),
|
'magenta' => array('set' => 35, 'unset' => 39),
|
||||||
'cyan' => array('set' => 36, 'unset' => 39),
|
'cyan' => array('set' => 36, 'unset' => 39),
|
||||||
'white' => array('set' => 37, 'unset' => 39),
|
'white' => array('set' => 37, 'unset' => 39),
|
||||||
|
'default' => array('set' => 39, 'unset' => 39),
|
||||||
);
|
);
|
||||||
private static $availableBackgroundColors = array(
|
private static $availableBackgroundColors = array(
|
||||||
'black' => array('set' => 40, 'unset' => 49),
|
'black' => array('set' => 40, 'unset' => 49),
|
||||||
@ -39,6 +40,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
|||||||
'magenta' => array('set' => 45, 'unset' => 49),
|
'magenta' => array('set' => 45, 'unset' => 49),
|
||||||
'cyan' => array('set' => 46, 'unset' => 49),
|
'cyan' => array('set' => 46, 'unset' => 49),
|
||||||
'white' => array('set' => 47, 'unset' => 49),
|
'white' => array('set' => 47, 'unset' => 49),
|
||||||
|
'default' => array('set' => 49, 'unset' => 49),
|
||||||
);
|
);
|
||||||
private static $availableOptions = array(
|
private static $availableOptions = array(
|
||||||
'bold' => array('set' => 1, 'unset' => 22),
|
'bold' => array('set' => 1, 'unset' => 22),
|
||||||
|
@ -20,7 +20,7 @@ namespace Symfony\Component\Console\Helper;
|
|||||||
*/
|
*/
|
||||||
class DebugFormatterHelper extends 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 $started = array();
|
||||||
private $count = -1;
|
private $count = -1;
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ class ProgressBar
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether to overwrite the progressbar, false for new line
|
* Sets whether to overwrite the progressbar, false for new line.
|
||||||
*
|
*
|
||||||
* @param bool $overwrite
|
* @param bool $overwrite
|
||||||
*/
|
*/
|
||||||
@ -401,8 +401,8 @@ class ProgressBar
|
|||||||
$this->max = $step;
|
$this->max = $step;
|
||||||
}
|
}
|
||||||
|
|
||||||
$prevPeriod = intval($this->step / $this->redrawFreq);
|
$prevPeriod = (int) ($this->step / $this->redrawFreq);
|
||||||
$currPeriod = intval($step / $this->redrawFreq);
|
$currPeriod = (int) ($step / $this->redrawFreq);
|
||||||
$this->step = $step;
|
$this->step = $step;
|
||||||
$this->percent = $this->max ? (float) $this->step / $this->max : 0;
|
$this->percent = $this->max ? (float) $this->step / $this->max : 0;
|
||||||
if ($prevPeriod !== $currPeriod || $this->max === $step) {
|
if ($prevPeriod !== $currPeriod || $this->max === $step) {
|
||||||
|
@ -161,7 +161,8 @@ class ChoiceQuestion extends Question
|
|||||||
if (false === $result) {
|
if (false === $result) {
|
||||||
throw new \InvalidArgumentException(sprintf($errorMessage, $value));
|
throw new \InvalidArgumentException(sprintf($errorMessage, $value));
|
||||||
}
|
}
|
||||||
array_push($multiselectChoices, (string) $result);
|
|
||||||
|
$multiselectChoices[] = $choices[(string) $result];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($multiselect) {
|
if ($multiselect) {
|
||||||
|
@ -37,6 +37,9 @@ class OutputFormatterStyleTest extends \PHPUnit_Framework_TestCase
|
|||||||
$style->setForeground('blue');
|
$style->setForeground('blue');
|
||||||
$this->assertEquals("\033[34mfoo\033[39m", $style->apply('foo'));
|
$this->assertEquals("\033[34mfoo\033[39m", $style->apply('foo'));
|
||||||
|
|
||||||
|
$style->setForeground('default');
|
||||||
|
$this->assertEquals("\033[39mfoo\033[39m", $style->apply('foo'));
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
$style->setForeground('undefined-color');
|
$style->setForeground('undefined-color');
|
||||||
}
|
}
|
||||||
@ -51,6 +54,9 @@ class OutputFormatterStyleTest extends \PHPUnit_Framework_TestCase
|
|||||||
$style->setBackground('yellow');
|
$style->setBackground('yellow');
|
||||||
$this->assertEquals("\033[43mfoo\033[49m", $style->apply('foo'));
|
$this->assertEquals("\033[43mfoo\033[49m", $style->apply('foo'));
|
||||||
|
|
||||||
|
$style->setBackground('default');
|
||||||
|
$this->assertEquals("\033[49mfoo\033[49m", $style->apply('foo'));
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
$style->setBackground('undefined-color');
|
$style->setBackground('undefined-color');
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ class DebugClassLoader
|
|||||||
}
|
}
|
||||||
if (self::$caseCheck && preg_match('#([/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*)+\.(php|hh)$#D', $file, $tail)) {
|
if (self::$caseCheck && preg_match('#([/\\\\][a-zA-Z_\x7F-\xFF][a-zA-Z0-9_\x7F-\xFF]*)+\.(php|hh)$#D', $file, $tail)) {
|
||||||
$tail = $tail[0];
|
$tail = $tail[0];
|
||||||
$real = $refl->getFilename();
|
$real = $refl->getFileName();
|
||||||
|
|
||||||
if (2 === self::$caseCheck) {
|
if (2 === self::$caseCheck) {
|
||||||
// realpath() on MacOSX doesn't normalize the case of characters
|
// realpath() on MacOSX doesn't normalize the case of characters
|
||||||
|
@ -112,10 +112,10 @@ class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
restore_exception_handler();
|
restore_exception_handler();
|
||||||
$this->assertStringStartsWith(__FILE__, $exception->getFile());
|
$this->assertStringStartsWith(__FILE__, $exception->getFile());
|
||||||
if (PHP_VERSION_ID < 70000) {
|
if (PHP_VERSION_ID < 70000) {
|
||||||
$this->assertRegexp('/^Runtime Notice: Declaration/', $exception->getMessage());
|
$this->assertRegExp('/^Runtime Notice: Declaration/', $exception->getMessage());
|
||||||
$this->assertEquals(E_STRICT, $exception->getSeverity());
|
$this->assertEquals(E_STRICT, $exception->getSeverity());
|
||||||
} else {
|
} else {
|
||||||
$this->assertRegexp('/^Warning: Declaration/', $exception->getMessage());
|
$this->assertRegExp('/^Warning: Declaration/', $exception->getMessage());
|
||||||
$this->assertEquals(E_WARNING, $exception->getSeverity());
|
$this->assertEquals(E_WARNING, $exception->getSeverity());
|
||||||
}
|
}
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
|
@ -77,7 +77,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals(E_NOTICE, $exception->getSeverity());
|
$this->assertEquals(E_NOTICE, $exception->getSeverity());
|
||||||
$this->assertEquals(__FILE__, $exception->getFile());
|
$this->assertEquals(__FILE__, $exception->getFile());
|
||||||
$this->assertRegexp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
|
$this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
|
||||||
$this->assertArrayHasKey('foobar', $exception->getContext());
|
$this->assertArrayHasKey('foobar', $exception->getContext());
|
||||||
|
|
||||||
$trace = $exception->getTrace();
|
$trace = $exception->getTrace();
|
||||||
|
@ -61,7 +61,7 @@ class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
array_map('spl_autoload_register', $autoloaders);
|
array_map('spl_autoload_register', $autoloaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
$this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
||||||
$this->assertSame($translatedMessage, $exception->getMessage());
|
$this->assertSame($translatedMessage, $exception->getMessage());
|
||||||
$this->assertSame($error['type'], $exception->getSeverity());
|
$this->assertSame($error['type'], $exception->getSeverity());
|
||||||
$this->assertSame($error['file'], $exception->getFile());
|
$this->assertSame($error['file'], $exception->getFile());
|
||||||
@ -195,6 +195,6 @@ class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$handler = new ClassNotFoundFatalErrorHandler();
|
$handler = new ClassNotFoundFatalErrorHandler();
|
||||||
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||||
|
|
||||||
$this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
$this->assertInstanceOf('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class UndefinedFunctionFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$handler = new UndefinedFunctionFatalErrorHandler();
|
$handler = new UndefinedFunctionFatalErrorHandler();
|
||||||
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||||
|
|
||||||
$this->assertInstanceof('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception);
|
$this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception);
|
||||||
// class names are case insensitive and PHP/HHVM do not return the same
|
// class names are case insensitive and PHP/HHVM do not return the same
|
||||||
$this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage()));
|
$this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage()));
|
||||||
$this->assertSame($error['type'], $exception->getSeverity());
|
$this->assertSame($error['type'], $exception->getSeverity());
|
||||||
|
@ -24,7 +24,7 @@ class UndefinedMethodFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$handler = new UndefinedMethodFatalErrorHandler();
|
$handler = new UndefinedMethodFatalErrorHandler();
|
||||||
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||||
|
|
||||||
$this->assertInstanceof('Symfony\Component\Debug\Exception\UndefinedMethodException', $exception);
|
$this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedMethodException', $exception);
|
||||||
$this->assertSame($translatedMessage, $exception->getMessage());
|
$this->assertSame($translatedMessage, $exception->getMessage());
|
||||||
$this->assertSame($error['type'], $exception->getSeverity());
|
$this->assertSame($error['type'], $exception->getSeverity());
|
||||||
$this->assertSame($error['file'], $exception->getFile());
|
$this->assertSame($error['file'], $exception->getFile());
|
||||||
|
@ -69,4 +69,14 @@ class FrozenParameterBag extends ParameterBag
|
|||||||
{
|
{
|
||||||
throw new LogicException('Impossible to call set() on a frozen 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()
|
public function testFormRegistrySetArrayOnNotCompoundField()
|
||||||
{
|
{
|
||||||
|
|
||||||
$registry = new FormFieldRegistry();
|
$registry = new FormFieldRegistry();
|
||||||
$registry->add($this->getFormFieldMock('bar'));
|
$registry->add($this->getFormFieldMock('bar'));
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
private $umask;
|
private $umask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string $workspace
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $workspace = null;
|
protected $workspace = null;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->umask = umask(0);
|
$this->umask = umask(0);
|
||||||
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().rand(0, 1000);
|
$this->workspace = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
|
||||||
mkdir($this->workspace, 0777, true);
|
mkdir($this->workspace, 0777, true);
|
||||||
$this->workspace = realpath($this->workspace);
|
$this->workspace = realpath($this->workspace);
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ class Command
|
|||||||
*/
|
*/
|
||||||
public function addAtIndex($bit, $index)
|
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;
|
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.
|
* Creates a new preloaded extension.
|
||||||
*
|
*
|
||||||
* @param FormTypeInterface[] $types The types 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 array[FormTypeExtensionInterface[]] $typeExtensions The type extensions that the extension should support.
|
||||||
* @param FormTypeGuesserInterface|null $typeGuesser The guesser 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)
|
public function __construct(array $types, array $typeExtensions, FormTypeGuesserInterface $typeGuesser = null)
|
||||||
{
|
{
|
||||||
|
@ -67,6 +67,14 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
|
|||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the singleton instance.
|
||||||
|
*/
|
||||||
|
public static function reset()
|
||||||
|
{
|
||||||
|
self::$instance = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers all natively provided mime type guessers.
|
* Registers all natively provided mime type guessers.
|
||||||
*/
|
*/
|
||||||
|
@ -517,7 +517,6 @@ class Request
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$content = '';
|
|
||||||
try {
|
try {
|
||||||
$content = $this->getContent();
|
$content = $this->getContent();
|
||||||
} catch (\LogicException $e) {
|
} catch (\LogicException $e) {
|
||||||
|
@ -126,7 +126,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||||||
private $lockMode = self::LOCK_TRANSACTIONAL;
|
private $lockMode = self::LOCK_TRANSACTIONAL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's an array to support multiple reads before closing which is manual, non-standard usage
|
* It's an array to support multiple reads before closing which is manual, non-standard usage.
|
||||||
*
|
*
|
||||||
* @var \PDOStatement[] An array of statements to release advisory locks
|
* @var \PDOStatement[] An array of statements to release advisory locks
|
||||||
*/
|
*/
|
||||||
@ -483,7 +483,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||||||
if ('sqlite' === $this->driver) {
|
if ('sqlite' === $this->driver) {
|
||||||
$this->pdo->exec('ROLLBACK');
|
$this->pdo->exec('ROLLBACK');
|
||||||
} else {
|
} else {
|
||||||
$this->pdo->rollback();
|
$this->pdo->rollBack();
|
||||||
}
|
}
|
||||||
$this->inTransaction = false;
|
$this->inTransaction = false;
|
||||||
}
|
}
|
||||||
@ -680,7 +680,7 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a PDO instance
|
* Return a PDO instance.
|
||||||
*
|
*
|
||||||
* @return \PDO
|
* @return \PDO
|
||||||
*/
|
*/
|
||||||
|
@ -203,7 +203,13 @@ class NativeSessionStorage implements SessionStorageInterface
|
|||||||
$this->metadataBag->stampNew();
|
$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());
|
$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()
|
public function testConstructWhenFileNotExists()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
|
@ -985,7 +985,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @dataProvider getContentCantBeCalledTwiceWithResourcesProvider
|
* @dataProvider getContentCantBeCalledTwiceWithResourcesProvider
|
||||||
*/
|
*/
|
||||||
public function testGetContentCanBeCalledTwiceWithResources($first, $second)
|
public function testGetContentCanBeCalledTwiceWithResources($first, $second)
|
||||||
|
@ -119,6 +119,17 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(11, $storage->getBag('attributes')->get('legs'));
|
$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()
|
public function testDefaultSessionCacheLimiter()
|
||||||
{
|
{
|
||||||
$this->iniSet('session.cache_limiter', 'nocache');
|
$this->iniSet('session.cache_limiter', 'nocache');
|
||||||
|
@ -34,7 +34,6 @@ class FragmentListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($request->query->has('_path'));
|
$this->assertTrue($request->query->has('_path'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testOnlyTriggeredIfControllerWasNotDefinedYet()
|
public function testOnlyTriggeredIfControllerWasNotDefinedYet()
|
||||||
{
|
{
|
||||||
$request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo');
|
$request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo');
|
||||||
|
@ -229,11 +229,11 @@ EOF;
|
|||||||
$conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
|
$conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
|
||||||
$hasTrailingSlash = true;
|
$hasTrailingSlash = true;
|
||||||
} else {
|
} else {
|
||||||
$conditions[] = sprintf("\$pathinfo === %s", var_export(str_replace('\\', '', $m['url']), true));
|
$conditions[] = sprintf('$pathinfo === %s', var_export(str_replace('\\', '', $m['url']), true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) {
|
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();
|
$regex = $compiledRoute->getRegex();
|
||||||
@ -241,7 +241,7 @@ EOF;
|
|||||||
$regex = substr($regex, 0, $pos).'/?$'.substr($regex, $pos + 2);
|
$regex = substr($regex, 0, $pos).'/?$'.substr($regex, $pos + 2);
|
||||||
$hasTrailingSlash = true;
|
$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;
|
$matches = true;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ class SecureRandomTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSerialCorrelation($secureRandom)
|
public function testSerialCorrelation($secureRandom)
|
||||||
{
|
{
|
||||||
$shift = rand(1, 5000);
|
$shift = mt_rand(1, 5000);
|
||||||
$b = $this->getBitSequence($secureRandom, 20000);
|
$b = $this->getBitSequence($secureRandom, 20000);
|
||||||
|
|
||||||
$Z = 0;
|
$Z = 0;
|
||||||
|
@ -30,7 +30,8 @@ class Groups
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @throws \InvalidArgumentException
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct(array $data)
|
public function __construct(array $data)
|
||||||
{
|
{
|
||||||
@ -52,7 +53,7 @@ class Groups
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets groups
|
* Gets groups.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -110,7 +110,7 @@ class ClassMetadata implements ClassMetadataInterface
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'name',
|
'name',
|
||||||
'attributes',
|
'attributesMetadata',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||||||
class GroupsTest extends \PHPUnit_Framework_TestCase
|
class GroupsTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testEmptyGroupsParameter()
|
public function testEmptyGroupsParameter()
|
||||||
{
|
{
|
||||||
@ -27,7 +27,7 @@ class GroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testNotAnArrayGroupsParameter()
|
public function testNotAnArrayGroupsParameter()
|
||||||
{
|
{
|
||||||
@ -35,7 +35,7 @@ class GroupsTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testInvalidGroupsParameter()
|
public function testInvalidGroupsParameter()
|
||||||
{
|
{
|
||||||
|
@ -54,4 +54,14 @@ class AttributeMetadataTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals(array('a', 'b', 'c'), $attributeMetadata1->getGroups());
|
$this->assertEquals(array('a', 'b', 'c'), $attributeMetadata1->getGroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSerialize()
|
||||||
|
{
|
||||||
|
$attributeMetadata = new AttributeMetadata('attribute');
|
||||||
|
$attributeMetadata->addGroup('a');
|
||||||
|
$attributeMetadata->addGroup('b');
|
||||||
|
|
||||||
|
$serialized = serialize($attributeMetadata);
|
||||||
|
$this->assertEquals($attributeMetadata, unserialize($serialized));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,4 +62,21 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals(array('a1' => $ac1), $classMetadata2->getAttributesMetadata());
|
$this->assertEquals(array('a1' => $ac1), $classMetadata2->getAttributesMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSerialize()
|
||||||
|
{
|
||||||
|
$classMetadata = new ClassMetadata('a');
|
||||||
|
|
||||||
|
$a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
|
||||||
|
$a1->method('getName')->willReturn('b1');
|
||||||
|
|
||||||
|
$a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
|
||||||
|
$a2->method('getName')->willReturn('b2');
|
||||||
|
|
||||||
|
$classMetadata->addAttributeMetadata($a1);
|
||||||
|
$classMetadata->addAttributeMetadata($a2);
|
||||||
|
|
||||||
|
$serialized = serialize($classMetadata);
|
||||||
|
$this->assertEquals($classMetadata, unserialize($serialized));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,7 +503,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testLegacyGetMessages($resources, $locale, $expected)
|
public function testLegacyGetMessages($resources, $locale, $expected)
|
||||||
{
|
{
|
||||||
$locales = array_keys($resources);
|
$locales = array_keys($resources);
|
||||||
$_locale = !is_null($locale) ? $locale : reset($locales);
|
$_locale = null !== $locale ? $locale : reset($locales);
|
||||||
$locales = array_slice($locales, 0, array_search($_locale, $locales));
|
$locales = array_slice($locales, 0, array_search($_locale, $locales));
|
||||||
|
|
||||||
$translator = new Translator($_locale, new MessageSelector());
|
$translator = new Translator($_locale, new MessageSelector());
|
||||||
|
Reference in New Issue
Block a user