Skip to content

Commit fef28b2

Browse files
committed
Merge branch '2.7' into 2.8
2 parents cbaa9c4 + 0bd8b58 commit fef28b2

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -499,27 +499,28 @@ public function testFailIfSetAllowedTypesFromLazyOption()
499499
}
500500

501501
/**
502-
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
503-
* @expectedExceptionMessage The option "foo" with value 42 is expected to be of type "string", but is of type "integer".
502+
* @dataProvider provideInvalidTypes
504503
*/
505-
public function testResolveFailsIfInvalidType()
504+
public function testResolveFailsIfInvalidType($actualType, $allowedType, $exceptionMessage)
506505
{
507-
$this->resolver->setDefined('foo');
508-
$this->resolver->setAllowedTypes('foo', 'string');
509-
510-
$this->resolver->resolve(array('foo' => 42));
506+
$this->resolver->setDefined('option');
507+
$this->resolver->setAllowedTypes('option', $allowedType);
508+
$this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', $exceptionMessage);
509+
$this->resolver->resolve(array('option' => $actualType));
511510
}
512511

513-
/**
514-
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
515-
* @expectedExceptionMessage The option "foo" with value null is expected to be of type "string", but is of type "NULL".
516-
*/
517-
public function testResolveFailsIfInvalidTypeIsNull()
512+
public function provideInvalidTypes()
518513
{
519-
$this->resolver->setDefault('foo', null);
520-
$this->resolver->setAllowedTypes('foo', 'string');
521-
522-
$this->resolver->resolve();
514+
return array(
515+
array(true, 'string', 'The option "option" with value true is expected to be of type "string", but is of type "boolean".'),
516+
array(false, 'string', 'The option "option" with value false is expected to be of type "string", but is of type "boolean".'),
517+
array(fopen(__FILE__, 'r'), 'string', 'The option "option" with value resource is expected to be of type "string", but is of type "resource".'),
518+
array(array(), 'string', 'The option "option" with value array is expected to be of type "string", but is of type "array".'),
519+
array(new OptionsResolver(), 'string', 'The option "option" with value Symfony\Component\OptionsResolver\OptionsResolver is expected to be of type "string", but is of type "Symfony\Component\OptionsResolver\OptionsResolver".'),
520+
array(42, 'string', 'The option "option" with value 42 is expected to be of type "string", but is of type "integer".'),
521+
array(null, 'string', 'The option "option" with value null is expected to be of type "string", but is of type "NULL".'),
522+
array('bar', '\stdClass', 'The option "option" with value "bar" is expected to be of type "\stdClass", but is of type "string".'),
523+
);
523524
}
524525

525526
public function testResolveSucceedsIfValidType()
@@ -550,17 +551,6 @@ public function testResolveSucceedsIfValidTypeMultiple()
550551
$this->assertNotEmpty($this->resolver->resolve());
551552
}
552553

553-
/**
554-
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
555-
*/
556-
public function testResolveFailsIfNotInstanceOfClass()
557-
{
558-
$this->resolver->setDefault('foo', 'bar');
559-
$this->resolver->setAllowedTypes('foo', '\stdClass');
560-
561-
$this->resolver->resolve();
562-
}
563-
564554
public function testResolveSucceedsIfInstanceOfClass()
565555
{
566556
$this->resolver->setDefault('foo', new \stdClass());

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy