diff --git a/.travis.yml b/.travis.yml
index fc5b3d775..5e1070765 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,7 +16,9 @@ matrix:
- php: '7.0'
env: COVERAGE='true'
- php: '7.0'
- env: SYMFONY_VERSION='^3.0'
+ env:
+ - COVERAGE='true'
+ - SYMFONY_VERSION='^3.0'
- php: '7.0'
env: SYMFONY_VERSION='^3.1'
- php: '7.0'
@@ -47,18 +49,9 @@ install:
script:
- |
if [ -n "$COVERAGE" ]; then
- phpdbg -qrr bin/phpunit -c $PHPUNIT_CONFIG $PHPUNIT_FLAGS --testdox --coverage-text --exclude-group=integration,symfony
- if [ -n "$SYMFONY_VERSION" ]; then
- phpdbg -qrr bin/phpunit -c $PHPUNIT_CONFIG $PHPUNIT_FLAGS --coverage-text --group=symfony
- else
- phpdbg -qrr bin/phpunit -c $PHPUNIT_CONFIG $PHPUNIT_FLAGS --coverage-text --group=integration --exclude-group=symfony
- fi
+ phpdbg -qrr bin/phpunit -c $PHPUNIT_CONFIG $PHPUNIT_FLAGS --testdox --coverage-text --exclude-group=integration
else
- if [ -n "$SYMFONY_VERSION" ]; then
- bin/phpunit -c $PHPUNIT_CONFIG $PHPUNIT_FLAGS --group=symfony
- else
- bin/phpunit -c $PHPUNIT_CONFIG $PHPUNIT_FLAGS --exclude-group=symfony
- fi
+ bin/phpunit -c $PHPUNIT_CONFIG $PHPUNIT_FLAGS
fi
notifications:
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 28d275711..63788159b 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -60,7 +60,9 @@
src
- src/Bridge
+
+ src/Bridge
+
diff --git a/src/Definition/Value/FixtureReferenceValue.php b/src/Definition/Value/FixtureReferenceValue.php
index 9972402b7..a9555cb68 100644
--- a/src/Definition/Value/FixtureReferenceValue.php
+++ b/src/Definition/Value/FixtureReferenceValue.php
@@ -31,11 +31,20 @@ final class FixtureReferenceValue implements ValueInterface
public function __construct($reference)
{
if (false === is_string($reference) && false === $reference instanceof ValueInterface) {
+ if (null === $reference) {
+ $referenceString = 'null';
+ } elseif (is_array($reference)) {
+ $referenceString = 'array';
+ } else {
+ $referenceString = is_scalar($reference) ? gettype($reference) : get_class($reference);
+ }
+
+ //TODO: move those exceptions into factories
throw new \InvalidArgumentException(
sprintf(
'Expected reference to be either a string or a "%s" instance, got "%s" instead.',
ValueInterface::class,
- is_scalar($reference) ? gettype($reference) : get_class($reference)
+ $referenceString
)
);
}
diff --git a/src/Definition/Value/ValueForCurrentValue.php b/src/Definition/Value/ValueForCurrentValue.php
index dcaf53c7d..c5c46412a 100644
--- a/src/Definition/Value/ValueForCurrentValue.php
+++ b/src/Definition/Value/ValueForCurrentValue.php
@@ -16,7 +16,7 @@
use Nelmio\Alice\Definition\ValueInterface;
/**
- * Value object representing ''.
+ * Value object placeholder for ''.
*/
final class ValueForCurrentValue implements ValueInterface
{
diff --git a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/AbstractChainableDenormalizer.php b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/AbstractChainableDenormalizer.php
index ffd302c30..108368c68 100644
--- a/src/FixtureBuilder/Denormalizer/Fixture/Chainable/AbstractChainableDenormalizer.php
+++ b/src/FixtureBuilder/Denormalizer/Fixture/Chainable/AbstractChainableDenormalizer.php
@@ -135,10 +135,6 @@ private function denormalizeTemporaryFixture(
FlagBag $flags
): array
{
- if (null === $this->denormalizer) {
- throw DenormalizerNotFoundException::createUnexpectedCall(__METHOD__);
- }
-
$tempFixtureId = uniqid('temporary_id');
$builtFixtures = $this->denormalizer->denormalize(
$builtFixtures,
diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParser.php
index 2bc8e08cd..6a8a42a88 100644
--- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParser.php
+++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/FixtureRangeReferenceTokenParser.php
@@ -59,7 +59,9 @@ public function parse(Token $token)
{
$range = $this->buildRange($token);
$references = [];
- for ($currentIndex = $range->getFrom(); $currentIndex <= $range->getTo(); $currentIndex++) {
+ $from = $range->getFrom();
+ $to = $range->getTo();
+ for ($currentIndex = $from; $currentIndex <= $to; $currentIndex++) {
$fixtureId = str_replace($this->token, $currentIndex, $range->getName());
$references[] = new FixtureReferenceValue($fixtureId);
}
diff --git a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php
index b9f83ef04..35a567ce1 100644
--- a/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php
+++ b/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParser.php
@@ -72,9 +72,6 @@ public function parse(Token $token)
{
$value = $this->tokenizer->detokenize($token->getValue());
$realValue = preg_replace('/^<\((.*)\)>$/', '', $value);
- if (null === $realValue) {
- throw ParseException::createForToken($token);
- }
return $this->decoratedTokenParser->parse(
new Token($realValue, new TokenType(TokenType::FUNCTION_TYPE))
diff --git a/src/Generator/ResolverGenerator.php b/src/Generator/ResolverGenerator.php
deleted file mode 100644
index 44e16749e..000000000
--- a/src/Generator/ResolverGenerator.php
+++ /dev/null
@@ -1,50 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-declare(strict_types=1);
-
-namespace Nelmio\Alice\Generator;
-
-use Nelmio\Alice\FixtureSet;
-use Nelmio\Alice\GeneratorInterface;
-use Nelmio\Alice\NotClonableTrait;
-use Nelmio\Alice\ObjectSet;
-
-final class ResolverGenerator implements GeneratorInterface
-{
- use NotClonableTrait;
-
- /**
- * @var FixtureSetResolverInterface
- */
- private $resolver;
-
- /**
- * @var GeneratorInterface
- */
- private $generator;
-
- public function __construct(FixtureSetResolverInterface $resolver, GeneratorInterface $generator)
- {
- $this->resolver = $resolver;
- $this->generator = $generator;
- }
-
- /**
- * @inheritdoc
- */
- public function generate(FixtureSet $fixtureSet): ObjectSet
- {
- $resolvedFixtureSet = $this->resolver->resolve($fixtureSet);
-
- return $this->generator->generate($resolvedFixtureSet);
- }
-}
diff --git a/src/NotClonableTrait.php b/src/NotClonableTrait.php
index 24b2f90e4..c5c00b266 100644
--- a/src/NotClonableTrait.php
+++ b/src/NotClonableTrait.php
@@ -17,6 +17,7 @@ trait NotClonableTrait
{
public function __clone()
{
+ //TODO: throw a custom exception
throw new \DomainException(
'This class is not clonable. This could be the case because this has not been needed yet. Do not hesitate '
.'to reach out the maintainers to know if this can be made clonable.'
diff --git a/tests/Definition/Fixture/TemplatingFixtureTest.php b/tests/Definition/Fixture/TemplatingFixtureTest.php
index 1225810f9..d89d394df 100644
--- a/tests/Definition/Fixture/TemplatingFixtureTest.php
+++ b/tests/Definition/Fixture/TemplatingFixtureTest.php
@@ -14,6 +14,7 @@
namespace Nelmio\Alice\Definition\Fixture;
use Nelmio\Alice\Definition\FakeMethodCall;
+use Nelmio\Alice\Definition\Flag\DummyFlag;
use Nelmio\Alice\Definition\Flag\ExtendFlag;
use Nelmio\Alice\Definition\Flag\TemplateFlag;
use Nelmio\Alice\Definition\FlagBag;
@@ -65,6 +66,7 @@ public function testReadAccessorsReturnPropertiesValues()
$this->assertTrue($fixture->isATemplate());
$this->assertTrue($fixture->extendsFixtures());
$this->assertEquals([new FixtureReference('user_base')], $fixture->getExtendedFixturesReferences());
+ $this->assertEquals($flags, $fixture->getFlags());
$decoratedFixtureProphecy->getId()->shouldHaveBeenCalledTimes(2);
$decoratedFixtureProphecy->getClassName()->shouldHaveBeenCalledTimes(1);
diff --git a/tests/Definition/Value/FixtureReferenceValueTest.php b/tests/Definition/Value/FixtureReferenceValueTest.php
index 55a85aa16..d8d4013ee 100644
--- a/tests/Definition/Value/FixtureReferenceValueTest.php
+++ b/tests/Definition/Value/FixtureReferenceValueTest.php
@@ -25,6 +25,82 @@ public function testIsAValue()
$this->assertTrue(is_a(FixtureReferenceValue::class, ValueInterface::class, true));
}
+ public function testCanBeInstantiatedWithOnlyAStringOrAValue()
+ {
+ new FixtureReferenceValue('user0');
+ new FixtureReferenceValue(new FakeValue());
+
+ try {
+ new FixtureReferenceValue(null);
+ } catch (\InvalidArgumentException $exception) {
+ $this->assertEquals(
+ 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got'
+ .' "null" instead.',
+ $exception->getMessage()
+ );
+ }
+
+ try {
+ new FixtureReferenceValue(true);
+ } catch (\InvalidArgumentException $exception) {
+ $this->assertEquals(
+ 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got'
+ .' "boolean" instead.',
+ $exception->getMessage()
+ );
+ }
+
+ try {
+ new FixtureReferenceValue(10);
+ } catch (\InvalidArgumentException $exception) {
+ $this->assertEquals(
+ 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got'
+ .' "integer" instead.',
+ $exception->getMessage()
+ );
+ }
+
+ try {
+ new FixtureReferenceValue(.5);
+ } catch (\InvalidArgumentException $exception) {
+ $this->assertEquals(
+ 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got'
+ .' "double" instead.',
+ $exception->getMessage()
+ );
+ }
+
+ try {
+ new FixtureReferenceValue([]);
+ } catch (\InvalidArgumentException $exception) {
+ $this->assertEquals(
+ 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got'
+ .' "array" instead.',
+ $exception->getMessage()
+ );
+ }
+
+ try {
+ new FixtureReferenceValue(new \stdClass());
+ } catch (\InvalidArgumentException $exception) {
+ $this->assertEquals(
+ 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got'
+ .' "stdClass" instead.',
+ $exception->getMessage()
+ );
+ }
+
+ try {
+ new FixtureReferenceValue(function () {});
+ } catch (\InvalidArgumentException $exception) {
+ $this->assertEquals(
+ 'Expected reference to be either a string or a "Nelmio\Alice\Definition\ValueInterface" instance, got'
+ .' "Closure" instead.',
+ $exception->getMessage()
+ );
+ }
+ }
+
public function testReadAccessorsReturnPropertiesValues()
{
$value = new FixtureReferenceValue('user0');
diff --git a/tests/Definition/Value/ValueForCurrentValueTest.php b/tests/Definition/Value/ValueForCurrentValueTest.php
new file mode 100644
index 000000000..043d70968
--- /dev/null
+++ b/tests/Definition/Value/ValueForCurrentValueTest.php
@@ -0,0 +1,39 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+declare(strict_types=1);
+
+namespace Nelmio\Alice\Definition\Value;
+
+use Nelmio\Alice\Definition\ValueInterface;
+
+/**
+ * @covers \Nelmio\Alice\Definition\Value\ValueForCurrentValue
+ */
+class ValueForCurrentValueTest extends \PHPUnit_Framework_TestCase
+{
+ public function testIsAValue()
+ {
+ $this->assertTrue(is_a(ValueForCurrentValue::class, ValueInterface::class, true));
+ }
+
+ public function testReadAccessorsReturnPropertiesValues()
+ {
+ $value = new ValueForCurrentValue();
+ $this->assertEquals('current', $value->getValue());
+ }
+
+ public function testCanBeCastedIntoAString()
+ {
+ $value = new ValueForCurrentValue();
+ $this->assertEquals('current', $value);
+ }
+}
diff --git a/tests/Exception/FixtureBuilder/Denormalizer/DenormalizerNotFoundExceptionTest.php b/tests/Exception/FixtureBuilder/Denormalizer/DenormalizerNotFoundExceptionTest.php
index c2330e929..1593d899b 100644
--- a/tests/Exception/FixtureBuilder/Denormalizer/DenormalizerNotFoundExceptionTest.php
+++ b/tests/Exception/FixtureBuilder/Denormalizer/DenormalizerNotFoundExceptionTest.php
@@ -38,6 +38,20 @@ public function testTestCreateNewExceptionWithFactoryForFixture()
'No suitable fixture denormalizer found to handle the fixture with the reference "foo".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error('hello');
+
+ $exception = DenormalizerNotFoundException::createForFixture('foo', $code, $previous);
+ $this->assertEquals(
+ 'No suitable fixture denormalizer found to handle the fixture with the reference "foo".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
public function testTestCreateNewExceptionWithFactoryForUnexpectedCall()
@@ -48,5 +62,32 @@ public function testTestCreateNewExceptionWithFactoryForUnexpectedCall()
'Expected method "fake" to be called only if it has a denormalizer.',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error('hello');
+
+ $exception = DenormalizerNotFoundException::createUnexpectedCall('fake', $code, $previous);
+ $this->assertEquals(
+ 'Expected method "fake" to be called only if it has a denormalizer.',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
+
+ public function testIsExtensible()
+ {
+ $exception = ChildDenormalizerNotFoundException::createForFixture('foo');
+ $this->assertInstanceOf(ChildDenormalizerNotFoundException::class, $exception);
+
+ $exception = ChildDenormalizerNotFoundException::createUnexpectedCall('fake');
+ $this->assertInstanceOf(ChildDenormalizerNotFoundException::class, $exception);
+ }
+}
+
+class ChildDenormalizerNotFoundException extends DenormalizerNotFoundException
+{
}
diff --git a/tests/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserNotFoundExceptionTest.php b/tests/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserNotFoundExceptionTest.php
index 767fe91b7..bac922f3a 100644
--- a/tests/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserNotFoundExceptionTest.php
+++ b/tests/Exception/FixtureBuilder/Denormalizer/FlagParser/FlagParserNotFoundExceptionTest.php
@@ -33,14 +33,19 @@ public function testIsNotADenormalizationThrowable()
public function testTestCreateNewException()
{
$exception = FlagParserNotFoundException::create('foo');
+
$this->assertEquals(
'No suitable flag parser found to handle the element "foo".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
- $code = 100;
- $previous = new \Exception();
+ $code = 500;
+ $previous = new \Error();
$exception = FlagParserNotFoundException::create('foo', $code, $previous);
+
$this->assertEquals(
'No suitable flag parser found to handle the element "foo".',
$exception->getMessage()
@@ -52,14 +57,19 @@ public function testTestCreateNewException()
public function testTestCreateNewExceptionForUnexpectedCall()
{
$exception = FlagParserNotFoundException::createUnexpectedCall('foo');
+
$this->assertEquals(
'Expected method "foo" to be called only if it has a flag parser.',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
- $code = 100;
- $previous = new \Exception();
+ $code = 500;
+ $previous = new \Error();
$exception = FlagParserNotFoundException::createUnexpectedCall('foo', $code, $previous);
+
$this->assertEquals(
'Expected method "foo" to be called only if it has a flag parser.',
$exception->getMessage()
diff --git a/tests/Exception/FixtureBuilder/Denormalizer/UnexpectedValueExceptionTest.php b/tests/Exception/FixtureBuilder/Denormalizer/UnexpectedValueExceptionTest.php
index 7a9232554..98a607219 100644
--- a/tests/Exception/FixtureBuilder/Denormalizer/UnexpectedValueExceptionTest.php
+++ b/tests/Exception/FixtureBuilder/Denormalizer/UnexpectedValueExceptionTest.php
@@ -29,4 +29,14 @@ public function testIsADenormalizationThrowable()
{
$this->assertTrue(is_a(UnexpectedValueException::class, DenormalizationThrowable::class, true));
}
+
+ public function testIsExtensible()
+ {
+ $exception = new ChildUnexpectedValueException();
+ $this->assertInstanceOf(ChildUnexpectedValueException::class, $exception);
+ }
+}
+
+class ChildUnexpectedValueException extends UnexpectedValueException
+{
}
diff --git a/tests/Exception/FixtureBuilder/ExpressionLanguage/LexExceptionTest.php b/tests/Exception/FixtureBuilder/ExpressionLanguage/LexExceptionTest.php
index 821e14f82..ab559c439 100644
--- a/tests/Exception/FixtureBuilder/ExpressionLanguage/LexExceptionTest.php
+++ b/tests/Exception/FixtureBuilder/ExpressionLanguage/LexExceptionTest.php
@@ -39,27 +39,27 @@ public function testCanCreateExceptionWithTheFactory()
);
$this->assertEquals(0, $exception->getCode());
$this->assertNull($exception->getPrevious());
- }
- public function testCanCreateExceptionWithTheFactoryWithASpecificCode()
- {
- $exception = LexException::create('foo', 10);
+
+ $code = 500;
+ $previous = new \Error('hello');
+
+ $exception = LexException::create('foo', $code, $previous);
$this->assertEquals(
'Could not lex the value "foo".',
$exception->getMessage()
);
- $this->assertEquals(10, $exception->getCode());
- $this->assertNull($exception->getPrevious());
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
- public function testCanCreateExceptionWithTheFactoryAndAPreviousException()
+ public function testIsExtensible()
{
- $exception = LexException::create('foo', 10, $previous = new \Exception());
- $this->assertEquals(
- 'Could not lex the value "foo".',
- $exception->getMessage()
- );
- $this->assertEquals(10, $exception->getCode());
- $this->assertSame($previous, $exception->getPrevious());
+ $exception = ChildLexException::create('foo');
+ $this->assertInstanceOf(ChildLexException::class, $exception);
}
}
+
+class ChildLexException extends LexException
+{
+}
diff --git a/tests/Exception/FixtureBuilder/ExpressionLanguage/ParseExceptionTest.php b/tests/Exception/FixtureBuilder/ExpressionLanguage/ParseExceptionTest.php
index 3786a3a0c..66936562f 100644
--- a/tests/Exception/FixtureBuilder/ExpressionLanguage/ParseExceptionTest.php
+++ b/tests/Exception/FixtureBuilder/ExpressionLanguage/ParseExceptionTest.php
@@ -36,35 +36,36 @@ public function testCanCreateExceptionWithTheFactory()
{
$token = new Token('foo', new TokenType(TokenType::DYNAMIC_ARRAY_TYPE));
$exception = ParseException::createForToken($token);
+
$this->assertEquals(
'Could not parse the token "foo" (type: DYNAMIC_ARRAY_TYPE).',
$exception->getMessage()
);
$this->assertEquals(0, $exception->getCode());
$this->assertNull($exception->getPrevious());
- }
- public function testCanCreateExceptionWithTheFactoryWithASpecificCode()
- {
- $token = new Token('foo', new TokenType(TokenType::DYNAMIC_ARRAY_TYPE));
- $exception = ParseException::createForToken($token, 10);
+
+ $code = 500;
+ $previous = new \Error('hello');
+
+ $exception = ParseException::createForToken($token, $code, $previous);
$this->assertEquals(
'Could not parse the token "foo" (type: DYNAMIC_ARRAY_TYPE).',
$exception->getMessage()
);
- $this->assertEquals(10, $exception->getCode());
- $this->assertNull($exception->getPrevious());
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
- public function testCanCreateExceptionWithTheFactoryAndAPreviousException()
+ public function testIsExtensible()
{
$token = new Token('foo', new TokenType(TokenType::DYNAMIC_ARRAY_TYPE));
- $exception = ParseException::createForToken($token, 10, $previous = new \Exception());
- $this->assertEquals(
- 'Could not parse the token "foo" (type: DYNAMIC_ARRAY_TYPE).',
- $exception->getMessage()
- );
- $this->assertEquals(10, $exception->getCode());
- $this->assertSame($previous, $exception->getPrevious());
+
+ $exception = ChildParseException::createForToken($token);
+ $this->assertInstanceOf(ChildParseException::class, $exception);
}
}
+
+class ChildParseException extends ParseException
+{
+}
diff --git a/tests/Exception/FixtureBuilder/ExpressionLanguage/ParserNotFoundExceptionTest.php b/tests/Exception/FixtureBuilder/ExpressionLanguage/ParserNotFoundExceptionTest.php
index 710878d70..a759fc257 100644
--- a/tests/Exception/FixtureBuilder/ExpressionLanguage/ParserNotFoundExceptionTest.php
+++ b/tests/Exception/FixtureBuilder/ExpressionLanguage/ParserNotFoundExceptionTest.php
@@ -41,6 +41,21 @@ public function testTestCreateNewExceptionForTokenWithTheFactory()
'No suitable token parser found to handle the token "foo" (type: DYNAMIC_ARRAY_TYPE).',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error('hello');
+
+ $exception = ParserNotFoundException::create($token, $code, $previous);
+ $this->assertEquals(
+ 'No suitable token parser found to handle the token "foo" (type: DYNAMIC_ARRAY_TYPE).',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
+
}
public function testTestCreateNewExceptionForUnexpectedCallWithTheFactory()
@@ -51,5 +66,34 @@ public function testTestCreateNewExceptionForUnexpectedCallWithTheFactory()
'Expected method "foo" to be called only if it has a parser.',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error('hello');
+
+ $exception = ParserNotFoundException::createUnexpectedCall('foo', $code, $previous);
+ $this->assertEquals(
+ 'Expected method "foo" to be called only if it has a parser.',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
+
+ public function testIsExtensible()
+ {
+ $token = new Token('foo', new TokenType(TokenType::DYNAMIC_ARRAY_TYPE));
+
+ $exception = ChildParserNotFoundException::create($token);
+ $this->assertInstanceOf(ChildParserNotFoundException::class, $exception);
+
+ $exception = ChildParserNotFoundException::createUnexpectedCall('foo');
+ $this->assertInstanceOf(ChildParserNotFoundException::class, $exception);
+ }
+}
+
+class ChildParserNotFoundException extends ParserNotFoundException
+{
}
diff --git a/tests/Exception/FixtureNotFoundExceptionTest.php b/tests/Exception/FixtureNotFoundExceptionTest.php
index acf359de5..54b7b3a85 100644
--- a/tests/Exception/FixtureNotFoundExceptionTest.php
+++ b/tests/Exception/FixtureNotFoundExceptionTest.php
@@ -31,5 +31,28 @@ public function testTestCreateNewExceptionWithFactory()
'Could not find the fixture "foo".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = FixtureNotFoundException::create('foo', $code, $previous);
+
+ $this->assertEquals(
+ 'Could not find the fixture "foo".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
+
+ public function testIsExtensible()
+ {
+ $exception = ChildFixtureNotFoundException::create('foo');
+ $this->assertInstanceOf(ChildFixtureNotFoundException::class, $exception);
+ }
+}
+
+class ChildFixtureNotFoundException extends FixtureNotFoundException
+{
}
diff --git a/tests/Exception/Generator/Hydrator/HydrationExceptionTest.php b/tests/Exception/Generator/Hydrator/HydrationExceptionTest.php
index f02c20fa6..d08fe78ca 100644
--- a/tests/Exception/Generator/Hydrator/HydrationExceptionTest.php
+++ b/tests/Exception/Generator/Hydrator/HydrationExceptionTest.php
@@ -42,6 +42,9 @@ public function testCreateExceptionViaFactory()
'Could not hydrate the property "foo" of the object "dummy" (class: stdClass).',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
$code = 100;
$previous = new \Error('hello');
@@ -62,12 +65,6 @@ public function testIsExtensible()
$exception = ChildHydrationException::create($object, $property);
$this->assertInstanceOf(ChildHydrationException::class, $exception);
-
- $code = 100;
- $previous = new \Error('hello');
-
- $exception = ChildHydrationException::create($object, $property, $code, $previous);
- $this->assertInstanceOf(ChildHydrationException::class, $exception);
}
}
diff --git a/tests/Exception/Generator/Hydrator/InvalidArgumentExceptionTest.php b/tests/Exception/Generator/Hydrator/InvalidArgumentExceptionTest.php
index 670474e15..3791500c2 100644
--- a/tests/Exception/Generator/Hydrator/InvalidArgumentExceptionTest.php
+++ b/tests/Exception/Generator/Hydrator/InvalidArgumentExceptionTest.php
@@ -42,6 +42,9 @@ public function testCreateExceptionViaFactory()
'Invalid value given for the property "foo" of the object "dummy" (class: stdClass).',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
$code = 100;
$previous = new \Error('hello');
@@ -62,12 +65,6 @@ public function testIsExtensible()
$exception = ChildInvalidArgumentException::create($object, $property);
$this->assertInstanceOf(ChildInvalidArgumentException::class, $exception);
-
- $code = 100;
- $previous = new \Error('hello');
-
- $exception = ChildInvalidArgumentException::create($object, $property, $code, $previous);
- $this->assertInstanceOf(ChildInvalidArgumentException::class, $exception);
}
}
diff --git a/tests/Exception/Generator/Hydrator/NoSuchPropertyExceptionTest.php b/tests/Exception/Generator/Hydrator/NoSuchPropertyExceptionTest.php
index f94591bbf..4cca0e92d 100644
--- a/tests/Exception/Generator/Hydrator/NoSuchPropertyExceptionTest.php
+++ b/tests/Exception/Generator/Hydrator/NoSuchPropertyExceptionTest.php
@@ -42,6 +42,9 @@ public function testCreateExceptionViaFactory()
'Could not hydrate the property "foo" of the object "dummy" (class: stdClass).',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
$code = 100;
$previous = new \Error('hello');
@@ -62,12 +65,6 @@ public function testIsExtensible()
$exception = ChildNoSuchPropertyException::create($object, $property);
$this->assertInstanceOf(ChildNoSuchPropertyException::class, $exception);
-
- $code = 100;
- $previous = new \Error('hello');
-
- $exception = ChildNoSuchPropertyException::create($object, $property, $code, $previous);
- $this->assertInstanceOf(ChildNoSuchPropertyException::class, $exception);
}
}
diff --git a/tests/Exception/Generator/Hydrator/PropertyAccessExceptionTest.php b/tests/Exception/Generator/Hydrator/PropertyAccessExceptionTest.php
index 0230ebdd9..2364fafd6 100644
--- a/tests/Exception/Generator/Hydrator/PropertyAccessExceptionTest.php
+++ b/tests/Exception/Generator/Hydrator/PropertyAccessExceptionTest.php
@@ -42,6 +42,9 @@ public function testCreateExceptionViaFactory()
'Could not access to the property "foo" of the object "dummy" (class: stdClass).',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
$code = 100;
$previous = new \Error('hello');
@@ -62,12 +65,6 @@ public function testIsExtensible()
$exception = ChildPropertyAccessException::create($object, $property);
$this->assertInstanceOf(ChildPropertyAccessException::class, $exception);
-
- $code = 100;
- $previous = new \Error('hello');
-
- $exception = ChildPropertyAccessException::create($object, $property, $code, $previous);
- $this->assertInstanceOf(ChildPropertyAccessException::class, $exception);
}
}
diff --git a/tests/Exception/Generator/Instantiator/InstantiationExceptionTest.php b/tests/Exception/Generator/Instantiator/InstantiationExceptionTest.php
index 915eb47dd..24931d11d 100644
--- a/tests/Exception/Generator/Instantiator/InstantiationExceptionTest.php
+++ b/tests/Exception/Generator/Instantiator/InstantiationExceptionTest.php
@@ -33,20 +33,35 @@ public function testIsAnInstantiationThrowable()
public function testTestCreateNewExceptionWithFactory()
{
- $exception0 = InstantiationException::create(new DummyFixture('foo'));
- $exception1 = InstantiationException::create(new DummyFixture('foo'), 10, $previous = new \Exception());
+ $exception = InstantiationException::create(new DummyFixture('foo'));
$this->assertEquals(
'Could not instantiate fixture "foo".',
- $exception0->getMessage()
+ $exception->getMessage()
);
- $this->assertNull($exception0->getPrevious());
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = InstantiationException::create(new DummyFixture('foo'), $code, $previous);
$this->assertEquals(
'Could not instantiate fixture "foo".',
- $exception1->getMessage()
+ $exception->getMessage()
);
- $this->assertEquals(10, $exception1->getCode());
- $this->assertSame($previous, $exception1->getPrevious());
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
+ }
+
+ public function testIsExtensible()
+ {
+ $exception = ChildInstantiationException::create(new DummyFixture('foo'));
+ $this->assertInstanceOf(ChildInstantiationException::class, $exception);
}
}
+
+class ChildInstantiationException extends InstantiationException
+{
+}
diff --git a/tests/Exception/Generator/Instantiator/InstantiatorNotFoundExceptionTest.php b/tests/Exception/Generator/Instantiator/InstantiatorNotFoundExceptionTest.php
index 03a94c74f..47ada7710 100644
--- a/tests/Exception/Generator/Instantiator/InstantiatorNotFoundExceptionTest.php
+++ b/tests/Exception/Generator/Instantiator/InstantiatorNotFoundExceptionTest.php
@@ -39,5 +39,29 @@ public function testTestCreateNewExceptionWithFactory()
'No suitable instantiator found for the fixture "foo".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = InstantiatorNotFoundException::create(new DummyFixture('foo'), $code, $previous);
+
+ $this->assertEquals(
+ 'No suitable instantiator found for the fixture "foo".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
+
+ public function testIsExtensible()
+ {
+ $exception = ChildInstantiatorNotFoundException::create(new DummyFixture('foo'));
+ $this->assertInstanceOf(ChildInstantiatorNotFoundException::class, $exception);
+ }
+}
+
+class ChildInstantiatorNotFoundException extends InstantiatorNotFoundException
+{
}
diff --git a/tests/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionTest.php b/tests/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionTest.php
index ee50ac694..f6b2a40e9 100644
--- a/tests/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionTest.php
+++ b/tests/Exception/Generator/ObjectGenerator/ObjectGeneratorNotFoundExceptionTest.php
@@ -38,5 +38,30 @@ public function testTestCreateNewExceptionWithFactory()
'Expected method "dummyMethod" to be called only if it has a generator.',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = ObjectGeneratorNotFoundException::createUnexpectedCall('dummyMethod', $code, $previous);
+
+ $this->assertEquals(
+ 'Expected method "dummyMethod" to be called only if it has a generator.',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
+ }
+
+ public function testIsExtensible()
+ {
+ $exception = ChildObjectGeneratorNotFoundException::createUnexpectedCall('dummyMethod');
+ $this->assertInstanceOf(ChildObjectGeneratorNotFoundException::class, $exception);
}
}
+
+class ChildObjectGeneratorNotFoundException extends ObjectGeneratorNotFoundException
+{
+}
+
diff --git a/tests/Exception/Generator/Resolver/CircularReferenceExceptionTest.php b/tests/Exception/Generator/Resolver/CircularReferenceExceptionTest.php
index bc64b06e3..9e73e742e 100644
--- a/tests/Exception/Generator/Resolver/CircularReferenceExceptionTest.php
+++ b/tests/Exception/Generator/Resolver/CircularReferenceExceptionTest.php
@@ -38,5 +38,30 @@ public function testTestCreateNewExceptionWithFactory()
'Circular reference detected for the parameter "foo" while resolving ["bar", "baz"].',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = CircularReferenceException::createForParameter('foo', ['bar' => 1, 'baz' => 0], $code, $previous);
+
+ $this->assertEquals(
+ 'Circular reference detected for the parameter "foo" while resolving ["bar", "baz"].',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
+ }
+
+ public function testIsExtensible()
+ {
+ $exception = ChildCircularReferenceException::createForParameter('foo', ['bar' => 1, 'baz' => 0]);
+ $this->assertInstanceOf(ChildCircularReferenceException::class, $exception);
}
}
+
+class ChildCircularReferenceException extends CircularReferenceException
+{
+}
+
diff --git a/tests/Exception/Generator/Resolver/RecursionLimitReachedExceptionTest.php b/tests/Exception/Generator/Resolver/RecursionLimitReachedExceptionTest.php
index 6608f57ce..701b7f6fe 100644
--- a/tests/Exception/Generator/Resolver/RecursionLimitReachedExceptionTest.php
+++ b/tests/Exception/Generator/Resolver/RecursionLimitReachedExceptionTest.php
@@ -38,5 +38,30 @@ public function testTestCreateNewExceptionWithFactory()
'Recursion limit (10 tries) reached while resolving the parameter "foo"',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = RecursionLimitReachedException::create(10, 'foo', $code, $previous);
+
+ $this->assertEquals(
+ 'Recursion limit (10 tries) reached while resolving the parameter "foo"',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
+ }
+
+ public function testIsExtensible()
+ {
+ $exception = ChildRecursionLimitReachedException::create(10, 'foo');
+ $this->assertInstanceOf(ChildRecursionLimitReachedException::class, $exception);
}
}
+
+class ChildRecursionLimitReachedException extends RecursionLimitReachedException
+{
+}
+
diff --git a/tests/Exception/Generator/Resolver/ResolverNotFoundExceptionTest.php b/tests/Exception/Generator/Resolver/ResolverNotFoundExceptionTest.php
index ea596ffb2..1c5a4f896 100644
--- a/tests/Exception/Generator/Resolver/ResolverNotFoundExceptionTest.php
+++ b/tests/Exception/Generator/Resolver/ResolverNotFoundExceptionTest.php
@@ -39,6 +39,20 @@ public function testTestCreateNewExceptionWithFactoryForParameter()
'No resolver found to resolve parameter "foo".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = ResolverNotFoundException::createForParameter('foo', $code, $previous);
+
+ $this->assertEquals(
+ 'No resolver found to resolve parameter "foo".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
public function testTestCreateNewExceptionWithFactoryForValue()
@@ -49,6 +63,20 @@ public function testTestCreateNewExceptionWithFactoryForValue()
'No resolver found to resolve value "dummy".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = ResolverNotFoundException::createForValue(new DummyValue('dummy'), $code, $previous);
+
+ $this->assertEquals(
+ 'No resolver found to resolve value "dummy".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
public function testTestCreateNewExceptionWithFactoryForUnexpectedCall()
@@ -59,5 +87,35 @@ public function testTestCreateNewExceptionWithFactoryForUnexpectedCall()
'Expected method "fake" to be called only if it has a resolver.',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = ResolverNotFoundException::createUnexpectedCall('fake', $code, $previous);
+
+ $this->assertEquals(
+ 'Expected method "fake" to be called only if it has a resolver.',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
+ }
+
+ public function testIsExtensible()
+ {
+ $exception = ChildResolverNotFoundException::createForParameter('foo');
+ $this->assertInstanceOf(ChildResolverNotFoundException::class, $exception);
+
+ $exception = ChildResolverNotFoundException::createForValue(new DummyValue('dummy'));
+ $this->assertInstanceOf(ChildResolverNotFoundException::class, $exception);
+
+ $exception = ChildResolverNotFoundException::createUnexpectedCall('fake');
+ $this->assertInstanceOf(ChildResolverNotFoundException::class, $exception);
}
}
+
+class ChildResolverNotFoundException extends ResolverNotFoundException
+{
+}
diff --git a/tests/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionTest.php b/tests/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionTest.php
index fd3eaf1e5..11b313b69 100644
--- a/tests/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionTest.php
+++ b/tests/Exception/Generator/Resolver/UniqueValueGenerationLimitReachedExceptionTest.php
@@ -42,5 +42,36 @@ public function testTestCreateNewExceptionWithFactory()
'Could not generate a unique value after 10 attempts for "unique_id".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = UniqueValueGenerationLimitReachedException::create(
+ new UniqueValue('unique_id', new \stdClass()),
+ 10,
+ $code,
+ $previous
+ );
+
+ $this->assertEquals(
+ 'Could not generate a unique value after 10 attempts for "unique_id".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
+
+ public function testIsExtensible()
+ {
+ $exception = ChildUniqueValueGenerationLimitReachedException::create(
+ new UniqueValue('unique_id', new \stdClass()),
+ 10
+ );
+ $this->assertInstanceOf(ChildUniqueValueGenerationLimitReachedException::class, $exception);
+ }
+}
+
+class ChildUniqueValueGenerationLimitReachedException extends UniqueValueGenerationLimitReachedException
+{
}
diff --git a/tests/Exception/ObjectNotFoundExceptionTest.php b/tests/Exception/ObjectNotFoundExceptionTest.php
index 0f026208e..89794b45b 100644
--- a/tests/Exception/ObjectNotFoundExceptionTest.php
+++ b/tests/Exception/ObjectNotFoundExceptionTest.php
@@ -31,5 +31,28 @@ public function testTestCreateNewExceptionWithFactory()
'Could not find the object "foo" of the class "Dummy".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = ObjectNotFoundException::create('foo', 'Dummy', $code, $previous);
+
+ $this->assertEquals(
+ 'Could not find the object "foo" of the class "Dummy".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
+
+ public function testIsExtensible()
+ {
+ $exception = ChildObjectNotFoundException::create('foo', 'Dummy');
+ $this->assertInstanceOf(ChildObjectNotFoundException::class, $exception);
+ }
+}
+
+class ChildObjectNotFoundException extends ObjectNotFoundException
+{
}
diff --git a/tests/Exception/ParameterNotFoundExceptionTest.php b/tests/Exception/ParameterNotFoundExceptionTest.php
index db195e2a1..cce2bf590 100644
--- a/tests/Exception/ParameterNotFoundExceptionTest.php
+++ b/tests/Exception/ParameterNotFoundExceptionTest.php
@@ -31,5 +31,29 @@ public function testTestCreateNewExceptionWithFactory()
'Could not find the parameter "foo".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = ParameterNotFoundException::create('foo', $code, $previous);
+
+ $this->assertEquals(
+ 'Could not find the parameter "foo".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
+
+ public function testIsExtensible()
+ {
+ $exception = ChildParameterNotFoundException::create('foo');
+ $this->assertInstanceOf(ChildParameterNotFoundException::class, $exception);
+ }
+}
+
+class ChildParameterNotFoundException extends ParameterNotFoundException
+{
}
diff --git a/tests/Exception/Parser/ParserNotFoundExceptionTest.php b/tests/Exception/Parser/ParserNotFoundExceptionTest.php
index 20cd65f34..a319ebd1e 100644
--- a/tests/Exception/Parser/ParserNotFoundExceptionTest.php
+++ b/tests/Exception/Parser/ParserNotFoundExceptionTest.php
@@ -38,5 +38,28 @@ public function testTestCreateNewExceptionWithFactory()
'No suitable parser found for the file "foo".',
$exception->getMessage()
);
+ $this->assertEquals(0, $exception->getCode());
+ $this->assertNull($exception->getPrevious());
+
+ $code = 500;
+ $previous = new \Error();
+ $exception = ParserNotFoundException::create('foo', $code, $previous);
+
+ $this->assertEquals(
+ 'No suitable parser found for the file "foo".',
+ $exception->getMessage()
+ );
+ $this->assertEquals($code, $exception->getCode());
+ $this->assertSame($previous, $exception->getPrevious());
}
+
+ public function testIsExtensible()
+ {
+ $exception = ChildParserNotFoundException::create('foo');
+ $this->assertInstanceOf(ChildParserNotFoundException::class, $exception);
+ }
+}
+
+class ChildParserNotFoundException extends ParserNotFoundException
+{
}
diff --git a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParserTest.php b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParserTest.php
index e9ae3d521..e2d924467 100644
--- a/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParserTest.php
+++ b/tests/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/IdentityTokenParserTest.php
@@ -16,6 +16,7 @@
use Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\ChainableTokenParserInterface;
use Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Token;
use Nelmio\Alice\FixtureBuilder\ExpressionLanguage\TokenType;
+use Prophecy\Argument;
/**
* @covers \Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\Chainable\IdentityTokenParser
@@ -45,5 +46,25 @@ public function testCanParseIdentityTokens()
$this->assertFalse($parser->canParse($anotherToken));
}
- //TODO
+ public function testReplaceIdentityIntoAFunctionCallBeforeHandingItOverToItsDecorated()
+ {
+ $token = new Token('<(echo "hello world!")>', new TokenType(TokenType::IDENTITY_TYPE));
+
+ $decoratedParserProphecy = $this->prophesize(ChainableTokenParserInterface::class);
+ $decoratedParserProphecy
+ ->parse(
+ new Token('', new TokenType(TokenType::FUNCTION_TYPE))
+ )
+ ->willReturn($expected = 'foo')
+ ;
+ /** @var ChainableTokenParserInterface $decoratedParser */
+ $decoratedParser = $decoratedParserProphecy->reveal();
+
+ $parser = new IdentityTokenParser($decoratedParser);
+ $actual = $parser->parse($token);
+
+ $this->assertEquals($expected, $actual);
+
+ $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1);
+ }
}