Skip to content

[2.7] Clean deprecated interfaces #15687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ORMQueryBuilderLoaderTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
* @group legacy
*/
public function testItOnlyWorksWithQueryBuilderOrClosure()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testCollapsedEntityField()
$this->setMaxRunningTime(1);

for ($i = 0; $i < 40; ++$i) {
$form = $this->factory->create('entity', null, array(
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
'class' => self::ENTITY_CLASS,
));

Expand All @@ -108,7 +108,7 @@ public function testCollapsedEntityFieldWithChoices()
$this->setMaxRunningTime(1);

for ($i = 0; $i < 40; ++$i) {
$form = $this->factory->create('entity', null, array(
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
'class' => self::ENTITY_CLASS,
'choices' => $choices,
));
Expand All @@ -127,7 +127,7 @@ public function testCollapsedEntityFieldWithPreferredChoices()
$this->setMaxRunningTime(1);

for ($i = 0; $i < 40; ++$i) {
$form = $this->factory->create('entity', null, array(
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
'class' => self::ENTITY_CLASS,
'preferred_choices' => $choices,
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function createListFromChoices($choices, $value = null)
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
* removed in Symfony 3.0.
*/
public function createListFromFlippedChoices($choices, $value = null)
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
{
if ($choices instanceof \Traversable) {
$choices = iterator_to_array($choices);
Expand All @@ -158,7 +158,7 @@ public function createListFromFlippedChoices($choices, $value = null)
$hash = self::generateHash(array($flatChoices, $value), 'fromFlippedChoices');

if (!isset($this->lists[$hash])) {
$this->lists[$hash] = $this->decoratedFactory->createListFromFlippedChoices($choices, $value);
$this->lists[$hash] = $this->decoratedFactory->createListFromFlippedChoices($choices, $value, $triggerDeprecationNotice);
}

return $this->lists[$hash];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ public function createListFromChoices($choices, $value = null)
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
* removed in Symfony 3.0.
*/
public function createListFromFlippedChoices($choices, $value = null)
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
{
if ($triggerDeprecationNotice) {
@trigger_error('The '.__METHOD__.' is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
}

return new ArrayKeyChoiceList($choices, $value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ public function createListFromChoices($choices, $value = null)
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
* removed in Symfony 3.0.
*/
public function createListFromFlippedChoices($choices, $value = null)
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
{
// Property paths are not supported here, because array keys can never
// be objects
return $this->decoratedFactory->createListFromFlippedChoices($choices, $value);
return $this->decoratedFactory->createListFromFlippedChoices($choices, $value, $triggerDeprecationNotice);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function configureOptions(OptionsResolver $resolver)

// BC when choices are in the keys, not in the values
if (!$options['choices_as_values']) {
return $choiceListFactory->createListFromFlippedChoices($choices, $options['choice_value']);
return $choiceListFactory->createListFromFlippedChoices($choices, $options['choice_value'], false);
}

return $choiceListFactory->createListFromChoices($choices, $options['choice_value']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public function testCreateFromChoicesDifferentValueClosure()
$this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2));
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesEmpty()
{
$list = new \stdClass();
Expand All @@ -168,6 +171,9 @@ public function testCreateFromFlippedChoicesEmpty()
$this->assertSame($list, $this->factory->createListFromFlippedChoices(array()));
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesComparesTraversableChoicesAsArray()
{
// The top-most traversable is converted to an array
Expand All @@ -184,6 +190,9 @@ public function testCreateFromFlippedChoicesComparesTraversableChoicesAsArray()
$this->assertSame($list, $this->factory->createListFromFlippedChoices($choices2));
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlattensChoices()
{
$choices1 = array('key' => array('a' => 'A'));
Expand All @@ -201,6 +210,7 @@ public function testCreateFromFlippedChoicesFlattensChoices()

/**
* @dataProvider provideSameKeyChoices
* @group legacy
*/
public function testCreateFromFlippedChoicesSameChoices($choice1, $choice2)
{
Expand All @@ -219,6 +229,7 @@ public function testCreateFromFlippedChoicesSameChoices($choice1, $choice2)

/**
* @dataProvider provideDistinguishedKeyChoices
* @group legacy
*/
public function testCreateFromFlippedChoicesDifferentChoices($choice1, $choice2)
{
Expand All @@ -240,6 +251,9 @@ public function testCreateFromFlippedChoicesDifferentChoices($choice1, $choice2)
$this->assertSame($list2, $this->factory->createListFromFlippedChoices($choices2));
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesSameValueClosure()
{
$choices = array(1);
Expand All @@ -255,6 +269,9 @@ public function testCreateFromFlippedChoicesSameValueClosure()
$this->assertSame($list, $this->factory->createListFromFlippedChoices($choices, $closure));
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesDifferentValueClosure()
{
$choices = array(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ function ($object) { return $object->value; }
$this->assertObjectListWithCustomValues($list);
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesEmpty()
{
$list = $this->factory->createListFromFlippedChoices(array());
Expand All @@ -201,6 +204,9 @@ public function testCreateFromFlippedChoicesEmpty()
$this->assertSame(array(), $list->getValues());
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlat()
{
$list = $this->factory->createListFromFlippedChoices(
Expand All @@ -210,6 +216,9 @@ public function testCreateFromFlippedChoicesFlat()
$this->assertScalarListWithChoiceValues($list);
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlatTraversable()
{
$list = $this->factory->createListFromFlippedChoices(
Expand All @@ -219,6 +228,9 @@ public function testCreateFromFlippedChoicesFlatTraversable()
$this->assertScalarListWithChoiceValues($list);
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlatValuesAsCallable()
{
$list = $this->factory->createListFromFlippedChoices(
Expand All @@ -229,6 +241,9 @@ public function testCreateFromFlippedChoicesFlatValuesAsCallable()
$this->assertScalarListWithCustomValues($list);
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlatValuesAsClosure()
{
$list = $this->factory->createListFromFlippedChoices(
Expand All @@ -246,6 +261,9 @@ function ($choice) {
$this->assertScalarListWithCustomValues($list);
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesGrouped()
{
$list = $this->factory->createListFromFlippedChoices(
Expand All @@ -258,6 +276,9 @@ public function testCreateFromFlippedChoicesGrouped()
$this->assertScalarListWithChoiceValues($list);
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesGroupedTraversable()
{
$list = $this->factory->createListFromFlippedChoices(
Expand All @@ -270,6 +291,9 @@ public function testCreateFromFlippedChoicesGroupedTraversable()
$this->assertScalarListWithChoiceValues($list);
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesGroupedValuesAsCallable()
{
$list = $this->factory->createListFromFlippedChoices(
Expand All @@ -283,6 +307,9 @@ public function testCreateFromFlippedChoicesGroupedValuesAsCallable()
$this->assertScalarListWithCustomValues($list);
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoicesGroupedValuesAsClosure()
{
$list = $this->factory->createListFromFlippedChoices(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public function testCreateFromChoicesPropertyPathInstance()
$this->assertSame(array('value'), $this->factory->createListFromChoices($choices, new PropertyPath('property')));
}

/**
* @group legacy
*/
public function testCreateFromFlippedChoices()
{
// Property paths are not supported here, because array keys can never
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

/**
* @author Bernhard Schussek <bschussek@gmail.com>
* @group legacy
*/
class LegacyChoiceListAdapterTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,7 @@ public function testPassPlaceholderToView($multiple, $expanded, $required, $plac

/**
* @dataProvider getOptionsWithPlaceholder
* @group legacy
*/
public function testPassEmptyValueBC($multiple, $expanded, $required, $placeholder, $viewValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ public function testPassPlaceholderAsString()
$this->assertSame('Empty', $view['time']['second']->vars['placeholder']);
}

/**
* @group legacy
*/
public function testPassEmptyValueBC()
{
$form = $this->factory->create('datetime', null, array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,9 @@ public function testPassPlaceholderAsString()
$this->assertSame('Empty', $view['day']->vars['placeholder']);
}

/**
* @group legacy
*/
public function testPassEmptyValueBC()
{
$form = $this->factory->create('date', null, array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ public function testPassPlaceholderAsString()
$this->assertSame('Empty', $view['second']->vars['placeholder']);
}

/**
* @group legacy
*/
public function testPassEmptyValueBC()
{
$form = $this->factory->create('time', null, array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function test2Dot5ValidationApi()
$this->assertInstanceOf('Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser', $guesser);
}

/**
* @group legacy
*/
public function test2Dot4ValidationApi()
{
$factory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
Expand Down Expand Up @@ -82,6 +85,7 @@ public function test2Dot4ValidationApi()

/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
* @group legacy
*/
public function testInvalidValidatorInterface()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function getMessageTemplate();
* @see getMessageTemplate()
*
* @api
*
* @deprecated since version 2.7, to be replaced by getParameters() in 3.0.
*/
public function getMessageParameters();

Expand All @@ -86,6 +88,8 @@ public function getMessageParameters();
* pluralization form (in this case "choices").
*
* @return int|null The number to use to pluralize of the message.
*
* @deprecated since version 2.7, to be replaced by getPlural() in 3.0.
*/
public function getMessagePluralization();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public function validate($object, Constraint $constraint)
$method($object, $this->context);
} elseif (is_array($method)) {
if (!is_callable($method)) {
throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1]));
if (isset($method[0]) && is_object($method[0])) {
$method[0] = get_class($method[0]);
}
throw new ConstraintDefinitionException(sprintf('%s targeted by Callback constraint is not a valid callable', json_encode($method)));
}

call_user_func($method, $object, $this->context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function testExpectValidMethods()
{
$object = new CallbackValidatorTest_Object();

$this->validator->validate($object, new Callback(array('foobar')));
$this->validator->validate($object, new Callback(array('callback' => array('foobar'))));
}

/**
Expand All @@ -308,7 +308,7 @@ public function testExpectValidCallbacks()
{
$object = new CallbackValidatorTest_Object();

$this->validator->validate($object, new Callback(array(array('foo', 'bar'))));
$this->validator->validate($object, new Callback(array('callback' => array('foo', 'bar'))));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ public function testAddCustomizedViolation()

/**
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
* @group legacy
*/
public function testMetadataMustImplementClassMetadataInterface()
{
Expand All @@ -561,6 +562,7 @@ public function testMetadataMustImplementClassMetadataInterface()

/**
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
* @group legacy
*/
public function testReferenceMetadataMustImplementClassMetadataInterface()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @since 2.5
*
* @author Bernhard Schussek <bschussek@gmail.com>
* @group legacy
*/
abstract class AbstractLegacyApiTest extends AbstractValidatorTest
{
Expand Down