minor #13268 [Form] fix Context\ExecutionContextInterface mock (nicolas-grekas)

This PR was merged into the 2.5 branch.

Discussion
----------

[Form] fix Context\ExecutionContextInterface mock

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Proper mock creation should fix tests on 2.6 once merged.

Commits
-------

d79aa70 [Form] fix Context\ExecutionContextInterface mock
This commit is contained in:
Fabien Potencier 2015-01-05 18:57:23 +01:00
commit 987717e40b
22 changed files with 58 additions and 45 deletions

View File

@ -269,7 +269,7 @@ class GenericEntityChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyInitShorthandEntityName()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$item1 = new SingleIntIdEntity(1, 'Foo');
$item2 = new SingleIntIdEntity(2, 'Bar');

View File

@ -206,7 +206,7 @@ class ModelChoiceListTest extends Propel1TestCase
public function testLegacygetIndicesForChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$item1 = new Item(1, 'Foo');
$item2 = new Item(2, 'Bar');
@ -230,7 +230,7 @@ class ModelChoiceListTest extends Propel1TestCase
public function testLegacyDifferentEqualObjectsAreChoosen()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$item = new Item(1, 'Foo');
@ -251,7 +251,7 @@ class ModelChoiceListTest extends Propel1TestCase
public function testLegacyGetIndicesForNullChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$item = new Item(1, 'Foo');
$choiceList = new ModelChoiceList(

View File

@ -482,7 +482,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testLegacyAsText()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$application = new Application();
$application->add(new \FooCommand());
@ -493,7 +493,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testLegacyAsXml()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$application = new Application();
$application->add(new \FooCommand());

View File

@ -320,7 +320,7 @@ class CommandTest extends \PHPUnit_Framework_TestCase
public function testLegacyAsText()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$command = new \TestCommand();
$command->setApplication(new Application());
@ -331,7 +331,7 @@ class CommandTest extends \PHPUnit_Framework_TestCase
public function testLegacyAsXml()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$command = new \TestCommand();
$command->setApplication(new Application());

View File

@ -375,7 +375,7 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
public function testLegacyAsText()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$definition = new InputDefinition(array(
new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'),
@ -392,7 +392,7 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
public function testLegacyAsXml()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$definition = new InputDefinition(array(
new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'),

View File

@ -43,7 +43,7 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
public function testLegacyInputOptionDefinitionInConstructor()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$definition = new InputDefinition(
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))

View File

@ -20,7 +20,7 @@ class DeprecationErrorHandler
{
public static function handle($errorNumber, $message, $file, $line, $context)
{
if ($errorNumber & E_USER_DEPRECATED) {
if ($errorNumber & ~E_USER_DEPRECATED) {
return true;
}
@ -29,7 +29,7 @@ class DeprecationErrorHandler
public static function handleBC($errorNumber, $message, $file, $line, $context)
{
if ($errorNumber & E_USER_DEPRECATED) {
if ($errorNumber & ~E_USER_DEPRECATED) {
return true;
}

View File

@ -163,7 +163,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$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));
@ -171,7 +171,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForChoicesPreservesKeys()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$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));
@ -179,7 +179,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForChoicesPreservesOrder()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$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));
@ -187,7 +187,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForChoicesIgnoresNonExistingChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$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));
@ -195,14 +195,14 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForChoicesEmpty()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertSame(array(), $this->list->getIndicesForChoices(array()));
}
public function testLegacyGetIndicesForValues()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// values and indices are always the same
$values = array($this->value1, $this->value2);
@ -211,7 +211,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForValuesPreservesKeys()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// values and indices are always the same
$values = array(5 => $this->value1, 8 => $this->value2);
@ -220,7 +220,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForValuesPreservesOrder()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$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));
@ -228,7 +228,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$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));
@ -236,7 +236,7 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForValuesEmpty()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertSame(array(), $this->list->getIndicesForValues(array()));
}

View File

@ -59,7 +59,7 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$choices = array('b', 'c');
$this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
@ -67,7 +67,7 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetIndicesForValues()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$values = array('b', 'c');
$this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));

View File

@ -187,7 +187,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
public function testLegacyGetIndicesForChoicesWithValuePath()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->list = new ObjectChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
@ -204,7 +204,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
public function testLegacyGetIndicesForChoicesWithValuePathPreservesKeys()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->list = new ObjectChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
@ -220,7 +220,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
public function testLegacyGetIndicesForChoicesWithValuePathPreservesOrder()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->list = new ObjectChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
@ -236,7 +236,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
public function testLegacyGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->list = new ObjectChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),

View File

@ -17,7 +17,7 @@ class SimpleNumericChoiceListTest extends AbstractChoiceListTest
{
public function testLegacyGetIndicesForChoicesDealsWithNumericChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// Pass choices as strings although they are integers
$choices = array('0', '1');
@ -26,7 +26,7 @@ class SimpleNumericChoiceListTest extends AbstractChoiceListTest
public function testLegacyGetIndicesForValuesDealsWithNumericValues()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// Pass values as strings although they are integers
$values = array('0', '1');

View File

@ -566,7 +566,20 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
private function getMockExecutionContext()
{
return $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
$context = $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
$contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
$validator->expects($this->any())
->method('inContext')
->with($context)
->will($this->returnValue($contextualValidator));
$context->expects($this->any())
->method('getValidator')
->will($this->returnValue($validator));
return $context;
}
/**

View File

@ -17,7 +17,7 @@ use Symfony\Component\Validator\Validation;
* @since 2.5.4
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class LegacyUserPasswordValidatorLegacyApiTest extends UserPasswordValidatorTest
class LegacyUserPasswordValidatorApiTest extends UserPasswordValidatorTest
{
protected function getApiVersion()
{

View File

@ -26,7 +26,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
public function testLegacyGetSetDebugger()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$loader = new ProjectTemplateLoader4();
$debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface');

View File

@ -54,7 +54,7 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
protected function setUp()
{
if (Validation::API_VERSION_2_5 !== $this->getApiVersion()) {
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
$this->group = 'MyGroup';

View File

@ -38,7 +38,7 @@ class LegacyExecutionContextTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->visitor = $this->getMockBuilder('Symfony\Component\Validator\ValidationVisitor')
->disableOriginalConstructor()

View File

@ -17,7 +17,7 @@ class LegacyApcCacheTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
if (!extension_loaded('apc') || !ini_get('apc.enable_cli')) {
$this->markTestSkipped('APC is not loaded.');

View File

@ -21,7 +21,7 @@ class LegacyElementMetadataTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->metadata = new TestElementMetadata();
}

View File

@ -635,7 +635,7 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
*/
public function testLegacyPropertyMetadataMustImplementPropertyMetadataInterface()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$entity = new Entity();

View File

@ -42,7 +42,7 @@ abstract class AbstractLegacyApiTest extends AbstractValidatorTest
protected function setUp()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
parent::setUp();

View File

@ -843,7 +843,7 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyValidatePropertyFailsIfPropertiesNotSupported()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// $metadata does not implement PropertyMetadataContainerInterface
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
@ -975,7 +975,7 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
*/
public function testLegacyValidatePropertyValueFailsIfPropertiesNotSupported()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
// $metadata does not implement PropertyMetadataContainerInterface
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');

View File

@ -112,7 +112,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testLegacyDefaultApiVersion()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
if (PHP_VERSION_ID < 50309) {
// Old implementation on PHP < 5.3.9
@ -125,7 +125,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testLegacySetApiVersion24()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_4));
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
@ -139,7 +139,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testLegacySetApiVersion24And25()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
if (PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Not supported prior to PHP 5.3.9');