Skip to content

Commit 68b8363

Browse files
Conditionally skip expression-related tests
In order to make the tests work with older versions of the Dependency Injection Component.
1 parent 5e4e90a commit 68b8363

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Tests/ArgumentValidatorTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public function testFailsWhenParameterHasArrayTypeHintButArgumentIsNotArray()
8686

8787
public function testFailsWhenResultOfExpressionIsNotAnObjectOfTheExpectedClass()
8888
{
89+
$this->skipTestIfExpressionsAreNotAvailable();
90+
8991
$class = 'Matthias\SymfonyServiceDefinitionValidator\Tests\Fixtures\ClassWithTypeHintedConstructorArgument';
9092

9193
$parameter = new \ReflectionParameter(array($class, '__construct'), 'expected');
@@ -103,6 +105,8 @@ public function testFailsWhenResultOfExpressionIsNotAnObjectOfTheExpectedClass()
103105

104106
public function testFailsWhenResultOfExpressionIsNotAnObject()
105107
{
108+
$this->skipTestIfExpressionsAreNotAvailable();
109+
106110
$class = 'Matthias\SymfonyServiceDefinitionValidator\Tests\Fixtures\ClassWithTypeHintedConstructorArgument';
107111

108112
$parameter = new \ReflectionParameter(array($class, '__construct'), 'expected');
@@ -117,6 +121,8 @@ public function testFailsWhenResultOfExpressionIsNotAnObject()
117121

118122
public function testFailsWhenResultOfExpressionIsNullButNullIsNotAllowed()
119123
{
124+
$this->skipTestIfExpressionsAreNotAvailable();
125+
120126
$class = 'Matthias\SymfonyServiceDefinitionValidator\Tests\Fixtures\ClassWithTypeHintedOptionalConstructorArgument';
121127

122128
$parameter = new \ReflectionParameter(array($class, '__construct'), 'expected');
@@ -133,6 +139,8 @@ public function testFailsWhenResultOfExpressionIsNullButNullIsNotAllowed()
133139

134140
public function testFailsIfSyntaxOfExpressionIsInvalid()
135141
{
142+
$this->skipTestIfExpressionsAreNotAvailable();
143+
136144
$class = 'Matthias\SymfonyServiceDefinitionValidator\Tests\Fixtures\ClassWithTypeHintedConstructorArgument';
137145

138146
$parameter = new \ReflectionParameter(array($class, '__construct'), 'expected');
@@ -147,6 +155,8 @@ public function testFailsIfSyntaxOfExpressionIsInvalid()
147155

148156
public function testFailsIfExpressionCouldNotBeEvaluated()
149157
{
158+
$this->skipTestIfExpressionsAreNotAvailable();
159+
150160
$class = 'Matthias\SymfonyServiceDefinitionValidator\Tests\Fixtures\ClassWithTypeHintedConstructorArgument';
151161

152162
$parameter = new \ReflectionParameter(array($class, '__construct'), 'expected');
@@ -163,4 +173,13 @@ private function createMockResultingClassResolver()
163173
{
164174
return $this->getMock('Matthias\SymfonyServiceDefinitionValidator\ResultingClassResolverInterface');
165175
}
176+
177+
private function skipTestIfExpressionsAreNotAvailable()
178+
{
179+
if (!class_exists('Symfony\Component\DependencyInjection\ExpressionLanguage')) {
180+
$this->markTestSkipped(
181+
'Expressions are not supported by this version of the DependencyInjection component'
182+
);
183+
}
184+
}
166185
}

0 commit comments

Comments
 (0)