1
|
|
|
<?php |
2
|
|
|
/******************************************************************************* |
3
|
|
|
* This file is part of the GraphQL Bundle package. |
4
|
|
|
* |
5
|
|
|
* (c) YnloUltratech <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
******************************************************************************/ |
10
|
|
|
|
11
|
|
|
namespace Ynlo\GraphQLBundle\Behat\Client; |
12
|
|
|
|
13
|
|
|
use Behat\Behat\Context\Environment\InitializedContextEnvironment; |
14
|
|
|
use Behat\Behat\EventDispatcher\Tester\EventDispatchingScenarioTester; |
15
|
|
|
use Behat\Behat\Tester\Result\StepResult; |
16
|
|
|
use Behat\Behat\Tester\ScenarioTester; |
17
|
|
|
use Behat\Behat\Tester\StepTester; |
18
|
|
|
use Behat\Gherkin\Node\FeatureNode; |
19
|
|
|
use Behat\Gherkin\Node\ScenarioInterface; |
20
|
|
|
use Behat\Gherkin\Node\StepNode; |
21
|
|
|
use Behat\Testwork\Environment\Environment; |
22
|
|
|
use Behat\Testwork\Tester\Result\TestResult; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Inject GraphQLClient instance on very context implementing ClientAwareInterface |
26
|
|
|
*/ |
27
|
|
|
class ClientAwareInitializer implements ScenarioTester |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var StepTester |
31
|
|
|
*/ |
32
|
|
|
private $baseTester; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var GraphQLClient |
36
|
|
|
*/ |
37
|
|
|
private $client; |
38
|
|
|
|
39
|
|
|
public function __construct(EventDispatchingScenarioTester $baseTester, GraphQLClient $client) |
40
|
|
|
{ |
41
|
|
|
$this->baseTester = $baseTester; |
|
|
|
|
42
|
|
|
$this->client = $client; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function setUp(Environment $env, FeatureNode $feature, ScenarioInterface $step, $skip) |
46
|
|
|
{ |
47
|
|
|
return $this->baseTester->setUp($env, $feature, $step, $skip); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function test(Environment $env, FeatureNode $feature, ScenarioInterface $step, $skip) |
51
|
|
|
{ |
52
|
|
|
/** @var InitializedContextEnvironment $env */ |
53
|
|
|
foreach ($env->getContexts() as $context) { |
|
|
|
|
54
|
|
|
if ($context instanceof ClientAwareInterface) { |
55
|
|
|
$context->setClient($this->client); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return $this->baseTester->test($env, $feature, $step, $skip); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function tearDown(Environment $env, FeatureNode $feature, ScenarioInterface $step, $skip, TestResult $result) |
63
|
|
|
{ |
64
|
|
|
return $this->baseTester->tearDown($env, $feature, $step, $skip, $result); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..