Skip to content

Commit 878ab23

Browse files
author
Jeremiah VALERIE
committed
Fix tests for sf <= 3.2
1 parent d0c9c10 commit 878ab23

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Tests/Functional/App/config/argumentWrapper/config.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ overblog_graphql:
1616
services:
1717
expression_function_instance_of:
1818
class: Symfony\Component\ExpressionLanguage\ExpressionFunction
19-
factory: Symfony\Component\ExpressionLanguage\ExpressionFunction::fromPhp
20-
arguments:
21-
- 'is_a'
19+
factory: Overblog\GraphQLBundle\Tests\Functional\TestCase::expressionFunctionFromPhp
20+
arguments: ['is_a']
2221
tags:
2322
- { name: overblog_graphql.expression_function }
23+
2424
expression_function_json_encode:
2525
class: Symfony\Component\ExpressionLanguage\ExpressionFunction
26-
factory: Symfony\Component\ExpressionLanguage\ExpressionFunction::fromPhp
27-
arguments:
28-
- 'json_encode'
26+
factory: Overblog\GraphQLBundle\Tests\Functional\TestCase::expressionFunctionFromPhp
27+
arguments: ['json_encode']
2928
tags:
3029
- { name: overblog_graphql.expression_function }

Tests/Functional/TestCase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Overblog\GraphQLBundle\Tests\Functional;
44

5+
use Overblog\GraphQLBundle\ExpressionLanguage\ExpressionFunction;
56
use Overblog\GraphQLBundle\Tests\Functional\App\TestKernel;
67
use Symfony\Bundle\FrameworkBundle\Client;
78
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -132,4 +133,15 @@ protected static function sendRequest(Client $client, $query, $isDecoded = false
132133

133134
return $isDecoded ? json_decode($result, true) : $result;
134135
}
136+
137+
public static function expressionFunctionFromPhp($phpFunctionName)
138+
{
139+
if (is_callable([ExpressionFunction::class, 'fromPhp'])) {
140+
return call_user_func([ExpressionFunction::class, 'fromPhp'], $phpFunctionName);
141+
}
142+
143+
return new ExpressionFunction($phpFunctionName, function () use ($phpFunctionName) {
144+
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', func_get_args()));
145+
});
146+
}
135147
}

0 commit comments

Comments
 (0)