Merge branch '2.7'
* 2.7: [Form] Make tested features configurable fix upgrade readme syntax [Form] Fix BC break introduced in #14050 [Form] Fix declaration of legacy tests Fix symfony/form dependend components [HttpKernel] Require symfony/debug < 3.0 [Bridge\PhpUnit] Relax silencing rule and fix phpunit runtime detection Conflicts: src/Symfony/Component/Form/Tests/AbstractLayoutTest.php src/Symfony/Component/HttpKernel/composer.json
This commit is contained in:
commit
a4cfcd1824
@ -356,6 +356,7 @@ Form
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
class MyEntityType extends DoctrineType
|
||||
{
|
||||
// ...
|
||||
@ -365,6 +366,7 @@ Form
|
||||
return new MyEntityLoader();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* `Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList` was
|
||||
deprecated and will be removed in Symfony 3.0. You should use
|
||||
@ -405,7 +407,7 @@ Form
|
||||
|
||||
Before:
|
||||
|
||||
```
|
||||
```php
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
|
||||
|
||||
$queryBuilder = function () {
|
||||
@ -416,7 +418,7 @@ Form
|
||||
|
||||
After:
|
||||
|
||||
```
|
||||
```php
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
|
||||
|
||||
// create $queryBuilder
|
||||
@ -435,7 +437,7 @@ Form
|
||||
|
||||
Before:
|
||||
|
||||
```
|
||||
```php
|
||||
$form->add('products', 'entity', array(
|
||||
'class' => 'AppBundle/Entity/Product',
|
||||
));
|
||||
@ -443,7 +445,7 @@ Form
|
||||
|
||||
After:
|
||||
|
||||
```
|
||||
```php
|
||||
$form->add('products', 'entity', array(
|
||||
'class' => 'AppBundle/Entity/Product',
|
||||
'choice_translation_domain' => true,
|
||||
|
@ -33,7 +33,7 @@ class DeprecationErrorHandler
|
||||
'legacy' => array(),
|
||||
'other' => array(),
|
||||
);
|
||||
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations) {
|
||||
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations, $mode) {
|
||||
if (E_USER_DEPRECATED !== $type) {
|
||||
return \PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
|
||||
}
|
||||
@ -51,10 +51,7 @@ class DeprecationErrorHandler
|
||||
|
||||
$group = 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($class, '\Legacy') || in_array('legacy', \PHPUnit_Util_Test::getGroups($class, $method), true) ? 'legacy' : 'remaining';
|
||||
|
||||
if ('legacy' === $group && 0 === (error_reporting() & E_USER_DEPRECATED)) {
|
||||
$ref =& $deprecations[$group]['Silenced']['count'];
|
||||
++$ref;
|
||||
} else {
|
||||
if ('legacy' !== $group && 'weak' !== $mode) {
|
||||
$ref =& $deprecations[$group][$msg]['count'];
|
||||
++$ref;
|
||||
$ref =& $deprecations[$group][$msg][$class.'::'.$method];
|
||||
@ -99,7 +96,7 @@ class DeprecationErrorHandler
|
||||
};
|
||||
|
||||
foreach (array('remaining', 'legacy', 'other') as $group) {
|
||||
if ($deprecations[$group]) {
|
||||
if ($deprecations[$group.'Count']) {
|
||||
echo "\n", $colorize(sprintf('%s deprecation notices (%d)', ucfirst($group), $deprecations[$group.'Count']), 'legacy' !== $group), "\n";
|
||||
|
||||
uasort($deprecations[$group], $cmp);
|
||||
@ -120,13 +117,8 @@ class DeprecationErrorHandler
|
||||
if (!empty($notices)) {
|
||||
echo "\n";
|
||||
}
|
||||
if ('weak' !== $mode) {
|
||||
if ($deprecations['remaining'] || $deprecations['other']) {
|
||||
exit(1);
|
||||
}
|
||||
if ('strict' === $mode && $deprecations['legacy'] && $deprecations['legacyCount'] !== $ref =& $deprecations['legacy']['Silenced']['count']) {
|
||||
exit(1);
|
||||
}
|
||||
if ('weak' !== $mode && ($deprecations['remaining'] || $deprecations['other'])) {
|
||||
exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -9,19 +9,13 @@ It comes with the following features:
|
||||
* auto-register `class_exists` to load Doctrine annotations;
|
||||
* print a user deprecation notices summary at the end of the test suite.
|
||||
|
||||
Handling user deprecation notices is sensitive to the SYMFONY_DEPRECATIONS_HELPER
|
||||
environment variable. This env var configures 3 behaviors depending on its value:
|
||||
By default any non-legacy-tagged deprecation notice will make tests fail.
|
||||
This can be changed by setting the SYMFONY_DEPRECATIONS_HELPER environment
|
||||
variable to `weak`. This will make the bridge ignore deprecation notices and
|
||||
is useful to projects that must use deprecated interfaces for backward
|
||||
compatibility reasons.
|
||||
|
||||
* when set to `strict`, all but silenced-legacy-tagged deprecation notices will
|
||||
make tests fail. This is the recommended mode for best forward compatibility
|
||||
* `weak` on the contrary will make tests ignore all deprecation notices.
|
||||
This is the recommended mode for legacy projects that must use deprecated
|
||||
interfaces for backward compatibility reasons.
|
||||
* with any other value, all but silenced-or-not-legacy-tagged deprecation
|
||||
notices will make tests fail.
|
||||
|
||||
All three modes will display a summary of deprecation notices at the end of the
|
||||
test suite, split in two groups:
|
||||
A summary of deprecation notices is displayed at the end of the test suite:
|
||||
|
||||
* **Legacy** deprecation notices denote tests that explicitly test some legacy
|
||||
interfaces. There are four ways to mark a test as legacy:
|
||||
@ -36,8 +30,7 @@ Usage
|
||||
-----
|
||||
|
||||
Add this bridge to the `require-dev` section of your composer.json file
|
||||
(not in `require`) with e.g.
|
||||
`composer require --dev "symfony/phpunit-bridge"`.
|
||||
(not in `require`) with e.g. `composer require --dev "symfony/phpunit-bridge"`.
|
||||
|
||||
When running `phpunit`, you will see a summary of deprecation notices at the end
|
||||
of the test suite.
|
||||
@ -48,15 +41,3 @@ You have to decide either to:
|
||||
* update your code to not use deprecated interfaces anymore, thus gaining better
|
||||
forward compatibility;
|
||||
* or move them to the **Legacy** section (by using one of the above way).
|
||||
|
||||
After reviewing them, you should silence deprecations in the **Legacy** section
|
||||
if you think they are triggered by tests dedicated to testing deprecated
|
||||
interfaces. To do so, add the following line at the beginning of your legacy
|
||||
test case or in the `setUp()` method of your legacy test class:
|
||||
`$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);`
|
||||
|
||||
Last but not least, you should then configure your C.I. to the reporting mode
|
||||
that is appropriated to your project by setting SYMFONY_DEPRECATIONS_HELPER to
|
||||
`strict`, `weak` or empty. It is recommended to start with `weak` mode, upgrade
|
||||
your code as described above, then when the *Remaining/Other* sections are empty,
|
||||
move to `strict` to keep forward compatibility on the long run.
|
||||
|
@ -3,7 +3,8 @@
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
|
||||
|
||||
if (!class_exists('PHPUnit_Util_ErrorHandler')) {
|
||||
// Detect if we're loaded by an actual run of phpunit
|
||||
if (!class_exists('PHPUnit_TextUI_Command', false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bridge\Twig\Extension;
|
||||
|
||||
use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererInterface;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
||||
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
||||
|
||||
/**
|
||||
* FormExtension extends Twig with form capabilities.
|
||||
|
@ -11,12 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\Form\ChoiceList\View;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\View\ChoiceView as LegacyChoiceView;
|
||||
|
||||
/**
|
||||
* Represents a choice in templates.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class ChoiceView
|
||||
class ChoiceView extends LegacyChoiceView
|
||||
{
|
||||
/**
|
||||
* The label displayed to humans.
|
||||
|
@ -11,18 +11,37 @@
|
||||
|
||||
namespace Symfony\Component\Form\Extension\Core\View;
|
||||
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView as BaseChoiceView;
|
||||
|
||||
/**
|
||||
* Represents a choice in templates.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
|
||||
* Use {@link BaseChoiceView} instead.
|
||||
* Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead.
|
||||
*/
|
||||
class ChoiceView extends BaseChoiceView
|
||||
class ChoiceView
|
||||
{
|
||||
/**
|
||||
* The original choice value.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* The view representation of the choice.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* The label displayed to humans.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* Creates a new ChoiceView.
|
||||
*
|
||||
@ -32,7 +51,9 @@ class ChoiceView extends BaseChoiceView
|
||||
*/
|
||||
public function __construct($data, $value, $label)
|
||||
{
|
||||
parent::__construct($label, $value, $data);
|
||||
$this->data = $data;
|
||||
$this->value = $value;
|
||||
$this->label = $label;
|
||||
|
||||
trigger_error('The '.__CLASS__.' class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\View\ChoiceView instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
||||
abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase
|
||||
{
|
||||
protected $csrfTokenManager;
|
||||
protected $testableFeatures = array();
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
|
@ -806,10 +806,8 @@ class CompoundFormTest extends AbstractFormTest
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetErrorsAsStringDeep()
|
||||
public function testGetErrorsAsStringDeep()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$parent = $this->getBuilder()
|
||||
->setCompound(true)
|
||||
->setDataMapper($this->getDataMapper())
|
||||
@ -830,10 +828,8 @@ class CompoundFormTest extends AbstractFormTest
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetErrorsAsStringDeepWithIndentation()
|
||||
public function testGetErrorsAsStringDeepWithIndentation()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$parent = $this->getBuilder()
|
||||
->setCompound(true)
|
||||
->setDataMapper($this->getDataMapper())
|
||||
|
@ -13,6 +13,8 @@ namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -123,8 +125,6 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->list = $this->createChoiceList();
|
||||
@ -153,151 +153,131 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testLegacyGetChoices()
|
||||
public function testGetChoices()
|
||||
{
|
||||
$this->assertSame($this->choices, $this->list->getChoices());
|
||||
}
|
||||
|
||||
public function testLegacyGetValues()
|
||||
public function testGetValues()
|
||||
{
|
||||
$this->assertSame($this->values, $this->list->getValues());
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForChoices()
|
||||
public function testGetIndicesForChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$choices = array($this->choice1, $this->choice2);
|
||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForChoicesPreservesKeys()
|
||||
public function testGetIndicesForChoicesPreservesKeys()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$choices = array(5 => $this->choice1, 8 => $this->choice2);
|
||||
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForChoicesPreservesOrder()
|
||||
public function testGetIndicesForChoicesPreservesOrder()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$choices = array($this->choice2, $this->choice1);
|
||||
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForChoicesIgnoresNonExistingChoices()
|
||||
public function testGetIndicesForChoicesIgnoresNonExistingChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$choices = array($this->choice1, $this->choice2, 'foobar');
|
||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForChoicesEmpty()
|
||||
public function testGetIndicesForChoicesEmpty()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->assertSame(array(), $this->list->getIndicesForChoices(array()));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForValues()
|
||||
public function testGetIndicesForValues()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
// values and indices are always the same
|
||||
$values = array($this->value1, $this->value2);
|
||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForValuesPreservesKeys()
|
||||
public function testGetIndicesForValuesPreservesKeys()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
// values and indices are always the same
|
||||
$values = array(5 => $this->value1, 8 => $this->value2);
|
||||
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForValuesPreservesOrder()
|
||||
public function testGetIndicesForValuesPreservesOrder()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$values = array($this->value2, $this->value1);
|
||||
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
|
||||
public function testGetIndicesForValuesIgnoresNonExistingValues()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$values = array($this->value1, $this->value2, 'foobar');
|
||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForValuesEmpty()
|
||||
public function testGetIndicesForValuesEmpty()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->assertSame(array(), $this->list->getIndicesForValues(array()));
|
||||
}
|
||||
|
||||
public function testLegacyGetChoicesForValues()
|
||||
public function testGetChoicesForValues()
|
||||
{
|
||||
$values = array($this->value1, $this->value2);
|
||||
$this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetChoicesForValuesPreservesKeys()
|
||||
public function testGetChoicesForValuesPreservesKeys()
|
||||
{
|
||||
$values = array(5 => $this->value1, 8 => $this->value2);
|
||||
$this->assertSame(array(5 => $this->choice1, 8 => $this->choice2), $this->list->getChoicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetChoicesForValuesPreservesOrder()
|
||||
public function testGetChoicesForValuesPreservesOrder()
|
||||
{
|
||||
$values = array($this->value2, $this->value1);
|
||||
$this->assertSame(array($this->choice2, $this->choice1), $this->list->getChoicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetChoicesForValuesIgnoresNonExistingValues()
|
||||
public function testGetChoicesForValuesIgnoresNonExistingValues()
|
||||
{
|
||||
$values = array($this->value1, $this->value2, 'foobar');
|
||||
$this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values));
|
||||
}
|
||||
|
||||
// https://github.com/symfony/symfony/issues/3446
|
||||
public function testLegacyGetChoicesForValuesEmpty()
|
||||
public function testGetChoicesForValuesEmpty()
|
||||
{
|
||||
$this->assertSame(array(), $this->list->getChoicesForValues(array()));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoices()
|
||||
public function testGetValuesForChoices()
|
||||
{
|
||||
$choices = array($this->choice1, $this->choice2);
|
||||
$this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesPreservesKeys()
|
||||
public function testGetValuesForChoicesPreservesKeys()
|
||||
{
|
||||
$choices = array(5 => $this->choice1, 8 => $this->choice2);
|
||||
$this->assertSame(array(5 => $this->value1, 8 => $this->value2), $this->list->getValuesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesPreservesOrder()
|
||||
public function testGetValuesForChoicesPreservesOrder()
|
||||
{
|
||||
$choices = array($this->choice2, $this->choice1);
|
||||
$this->assertSame(array($this->value2, $this->value1), $this->list->getValuesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesIgnoresNonExistingChoices()
|
||||
public function testGetValuesForChoicesIgnoresNonExistingChoices()
|
||||
{
|
||||
$choices = array($this->choice1, $this->choice2, 'foobar');
|
||||
$this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesEmpty()
|
||||
public function testGetValuesForChoicesEmpty()
|
||||
{
|
||||
$this->assertSame(array(), $this->list->getValuesForChoices(array()));
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class ChoiceListTest extends AbstractChoiceListTest
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testLegacyInitArray()
|
||||
public function testInitArray()
|
||||
{
|
||||
$this->list = new ChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
@ -56,7 +56,7 @@ class ChoiceListTest extends AbstractChoiceListTest
|
||||
* choices parameter. A choice itself that is an object implementing \Traversable
|
||||
* is not treated as hierarchical structure, but as-is.
|
||||
*/
|
||||
public function testLegacyInitNestedTraversable()
|
||||
public function testInitNestedTraversable()
|
||||
{
|
||||
$traversableChoice = new \ArrayIterator(array($this->obj3, $this->obj4));
|
||||
|
||||
@ -83,7 +83,7 @@ class ChoiceListTest extends AbstractChoiceListTest
|
||||
), $this->list->getRemainingViews());
|
||||
}
|
||||
|
||||
public function testLegacyInitNestedArray()
|
||||
public function testInitNestedArray()
|
||||
{
|
||||
$this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
|
||||
$this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
|
||||
@ -100,7 +100,7 @@ class ChoiceListTest extends AbstractChoiceListTest
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testLegacyInitWithInsufficientLabels()
|
||||
public function testInitWithInsufficientLabels()
|
||||
{
|
||||
$this->list = new ChoiceList(
|
||||
array($this->obj1, $this->obj2),
|
||||
@ -108,7 +108,7 @@ class ChoiceListTest extends AbstractChoiceListTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testLegacyInitWithLabelsContainingNull()
|
||||
public function testInitWithLabelsContainingNull()
|
||||
{
|
||||
$this->list = new ChoiceList(
|
||||
array($this->obj1, $this->obj2),
|
||||
|
@ -43,55 +43,45 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||
$this->list = null;
|
||||
}
|
||||
|
||||
public function testLegacyGetChoices()
|
||||
public function testGetChoices()
|
||||
{
|
||||
$this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices());
|
||||
}
|
||||
|
||||
public function testLegacyGetValues()
|
||||
public function testGetValues()
|
||||
{
|
||||
$this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues());
|
||||
}
|
||||
|
||||
public function testLegacyGetPreferredViews()
|
||||
public function testGetPreferredViews()
|
||||
{
|
||||
$this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews());
|
||||
}
|
||||
|
||||
public function testLegacyGetRemainingViews()
|
||||
public function testGetRemainingViews()
|
||||
{
|
||||
$this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetIndicesForChoices()
|
||||
public function testGetIndicesForChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$choices = array('b', 'c');
|
||||
$this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetIndicesForValues()
|
||||
public function testGetIndicesForValues()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$values = array('b', 'c');
|
||||
$this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetChoicesForValues()
|
||||
public function testGetChoicesForValues()
|
||||
{
|
||||
$values = array('b', 'c');
|
||||
$this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoices()
|
||||
public function testGetValuesForChoices()
|
||||
{
|
||||
$choices = array('b', 'c');
|
||||
$this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices));
|
||||
@ -100,7 +90,7 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testLegacyLoadChoiceListShouldReturnChoiceList()
|
||||
public function testLoadChoiceListShouldReturnChoiceList()
|
||||
{
|
||||
$list = new LazyChoiceListTest_InvalidImpl();
|
||||
|
||||
|
@ -52,7 +52,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testLegacyInitArray()
|
||||
public function testInitArray()
|
||||
{
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
@ -66,7 +66,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews());
|
||||
}
|
||||
|
||||
public function testLegacyInitNestedArray()
|
||||
public function testInitNestedArray()
|
||||
{
|
||||
$this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
|
||||
$this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
|
||||
@ -80,7 +80,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
), $this->list->getRemainingViews());
|
||||
}
|
||||
|
||||
public function testLegacyInitArrayWithGroupPath()
|
||||
public function testInitArrayWithGroupPath()
|
||||
{
|
||||
$this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1');
|
||||
$this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1');
|
||||
@ -118,7 +118,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testLegacyInitArrayWithGroupPathThrowsExceptionIfNestedArray()
|
||||
public function testInitArrayWithGroupPathThrowsExceptionIfNestedArray()
|
||||
{
|
||||
$this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1');
|
||||
$this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1');
|
||||
@ -136,7 +136,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testLegacyInitArrayWithValuePath()
|
||||
public function testInitArrayWithValuePath()
|
||||
{
|
||||
$this->obj1 = (object) array('name' => 'A', 'id' => 10);
|
||||
$this->obj2 = (object) array('name' => 'B', 'id' => 20);
|
||||
@ -157,7 +157,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertEquals(array(0 => new ChoiceView($this->obj1, '10', 'A'), 3 => new ChoiceView($this->obj4, '40', 'D')), $this->list->getRemainingViews());
|
||||
}
|
||||
|
||||
public function testLegacyInitArrayUsesToString()
|
||||
public function testInitArrayUsesToString()
|
||||
{
|
||||
$this->obj1 = new ObjectChoiceListTest_EntityWithToString('A');
|
||||
$this->obj2 = new ObjectChoiceListTest_EntityWithToString('B');
|
||||
@ -176,7 +176,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\StringCastException
|
||||
*/
|
||||
public function testLegacyInitArrayThrowsExceptionIfToStringNotFound()
|
||||
public function testInitArrayThrowsExceptionIfToStringNotFound()
|
||||
{
|
||||
$this->obj1 = new ObjectChoiceListTest_EntityWithToString('A');
|
||||
$this->obj2 = new ObjectChoiceListTest_EntityWithToString('B');
|
||||
@ -188,13 +188,8 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetIndicesForChoicesWithValuePath()
|
||||
public function testGetIndicesForChoicesWithValuePath()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
'name',
|
||||
@ -208,13 +203,8 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetIndicesForChoicesWithValuePathPreservesKeys()
|
||||
public function testGetIndicesForChoicesWithValuePathPreservesKeys()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
'name',
|
||||
@ -227,13 +217,8 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetIndicesForChoicesWithValuePathPreservesOrder()
|
||||
public function testGetIndicesForChoicesWithValuePathPreservesOrder()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
'name',
|
||||
@ -246,13 +231,8 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
|
||||
public function testGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
'name',
|
||||
@ -265,7 +245,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesWithValuePath()
|
||||
public function testGetValuesForChoicesWithValuePath()
|
||||
{
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
@ -279,7 +259,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertSame(array('A', 'B'), $this->list->getValuesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesWithValuePathPreservesKeys()
|
||||
public function testGetValuesForChoicesWithValuePathPreservesKeys()
|
||||
{
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
@ -293,7 +273,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertSame(array(5 => 'A', 8 => 'B'), $this->list->getValuesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesWithValuePathPreservesOrder()
|
||||
public function testGetValuesForChoicesWithValuePathPreservesOrder()
|
||||
{
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
@ -307,7 +287,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertSame(array('B', 'A'), $this->list->getValuesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesWithValuePathIgnoresNonExistingChoices()
|
||||
public function testGetValuesForChoicesWithValuePathIgnoresNonExistingChoices()
|
||||
{
|
||||
$this->list = new ObjectChoiceList(
|
||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
||||
*/
|
||||
class SimpleChoiceListTest extends AbstractChoiceListTest
|
||||
{
|
||||
public function testLegacyInitArray()
|
||||
public function testInitArray()
|
||||
{
|
||||
$choices = array('a' => 'A', 'b' => 'B', 'c' => 'C');
|
||||
$this->list = new SimpleChoiceList($choices, array('b'));
|
||||
@ -30,7 +30,7 @@ class SimpleChoiceListTest extends AbstractChoiceListTest
|
||||
$this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews());
|
||||
}
|
||||
|
||||
public function testLegacyInitNestedArray()
|
||||
public function testInitNestedArray()
|
||||
{
|
||||
$this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getChoices());
|
||||
$this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getValues());
|
||||
@ -47,7 +47,7 @@ class SimpleChoiceListTest extends AbstractChoiceListTest
|
||||
/**
|
||||
* @dataProvider dirtyValuesProvider
|
||||
*/
|
||||
public function testLegacyGetValuesForChoicesDealsWithDirtyValues($choice, $value)
|
||||
public function testGetValuesForChoicesDealsWithDirtyValues($choice, $value)
|
||||
{
|
||||
$choices = array(
|
||||
'0' => 'Zero',
|
||||
|
@ -18,32 +18,28 @@ use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
|
||||
*/
|
||||
class SimpleNumericChoiceListTest extends AbstractChoiceListTest
|
||||
{
|
||||
public function testLegacyGetIndicesForChoicesDealsWithNumericChoices()
|
||||
public function testGetIndicesForChoicesDealsWithNumericChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
// Pass choices as strings although they are integers
|
||||
$choices = array('0', '1');
|
||||
$this->assertSame(array(0, 1), $this->list->getIndicesForChoices($choices));
|
||||
}
|
||||
|
||||
public function testLegacyGetIndicesForValuesDealsWithNumericValues()
|
||||
public function testGetIndicesForValuesDealsWithNumericValues()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
// Pass values as strings although they are integers
|
||||
$values = array('0', '1');
|
||||
$this->assertSame(array(0, 1), $this->list->getIndicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetChoicesForValuesDealsWithNumericValues()
|
||||
public function testGetChoicesForValuesDealsWithNumericValues()
|
||||
{
|
||||
// Pass values as strings although they are integers
|
||||
$values = array('0', '1');
|
||||
$this->assertSame(array(0, 1), $this->list->getChoicesForValues($values));
|
||||
}
|
||||
|
||||
public function testLegacyGetValuesForChoicesDealsWithNumericValues()
|
||||
public function testGetValuesForChoicesDealsWithNumericValues()
|
||||
{
|
||||
// Pass values as strings although they are integers
|
||||
$values = array('0', '1');
|
||||
|
@ -24,8 +24,6 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->choiceList = new SimpleChoiceList(array('' => 'Empty', 0 => 'A', 1 => 'B'));
|
||||
@ -38,7 +36,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$listener = null;
|
||||
}
|
||||
|
||||
public function testLegacyFixRadio()
|
||||
public function testFixRadio()
|
||||
{
|
||||
$data = '1';
|
||||
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
|
||||
@ -51,7 +49,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array(2 => '1'), $event->getData());
|
||||
}
|
||||
|
||||
public function testLegacyFixZero()
|
||||
public function testFixZero()
|
||||
{
|
||||
$data = '0';
|
||||
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
|
||||
@ -64,7 +62,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array(1 => '0'), $event->getData());
|
||||
}
|
||||
|
||||
public function testLegacyFixEmptyString()
|
||||
public function testFixEmptyString()
|
||||
{
|
||||
$data = '';
|
||||
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
|
||||
@ -77,7 +75,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array(0 => ''), $event->getData());
|
||||
}
|
||||
|
||||
public function testLegacyConvertEmptyStringToPlaceholderIfNotFound()
|
||||
public function testConvertEmptyStringToPlaceholderIfNotFound()
|
||||
{
|
||||
$list = new SimpleChoiceList(array(0 => 'A', 1 => 'B'));
|
||||
|
||||
@ -91,7 +89,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array('placeholder' => ''), $event->getData());
|
||||
}
|
||||
|
||||
public function testLegacyDontConvertEmptyStringToPlaceholderIfNoPlaceholderUsed()
|
||||
public function testDontConvertEmptyStringToPlaceholderIfNoPlaceholderUsed()
|
||||
{
|
||||
$list = new SimpleChoiceList(array(0 => 'A', 1 => 'B'));
|
||||
|
||||
|
@ -373,8 +373,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||
*/
|
||||
public function testLegacySubmitSingleNonExpandedObjectChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$form = $this->factory->create('choice', null, array(
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
@ -493,8 +491,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||
*/
|
||||
public function testLegacySubmitMultipleNonExpandedObjectChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$form = $this->factory->create('choice', null, array(
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
@ -974,8 +970,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||
*/
|
||||
public function testLegacySubmitSingleExpandedObjectChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$form = $this->factory->create('choice', null, array(
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
@ -1202,8 +1196,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||
*/
|
||||
public function testLegacySubmitMultipleExpandedObjectChoices()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$form = $this->factory->create('choice', null, array(
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
|
@ -640,10 +640,8 @@ class FormTypeTest extends BaseTypeTest
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyCanGetErrorsWhenButtonInForm()
|
||||
public function testCanGetErrorsWhenButtonInForm()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$builder = $this->factory->createBuilder('form', null, array(
|
||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||
'required' => false,
|
||||
|
@ -735,10 +735,8 @@ class SimpleFormTest extends AbstractFormTest
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyGetErrorsAsString()
|
||||
public function testGetErrorsAsString()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$this->form->addError(new FormError('Error!'));
|
||||
|
||||
$this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString());
|
||||
|
Reference in New Issue
Block a user