1+ <?php
2+
3+ use PHPUnit \Framework \Assert ;
4+ use Symfony \Bundle \FrameworkBundle \Console \Application ;
5+ use Symfony \Component \Console \Input \ArrayInput ;
6+ use Symfony \Component \Console \Output \BufferedOutput ;
7+ use Symfony \Component \Finder \Finder ;
8+ use Symfony \Component \Filesystem \Filesystem ;
9+ use Symfony \Component \HttpKernel \KernelInterface ;
10+ use Symfony \Component \Process \PhpExecutableFinder ;
11+ use Symfony \Component \Process \Process ;
12+
13+ /**
14+ * @copyright Copyright (C) eZ Systems AS. All rights reserved.
15+ * @license For full copyright and license information view LICENSE file distributed with this source code.
16+ */
17+
18+ class GeneratorContext implements \Behat \Symfony2Extension \Context \KernelAwareContext
19+ {
20+ /**
21+ * @var string
22+ */
23+ private $ scriptOutput ;
24+
25+ /**
26+ * @var \Symfony\Component\HttpKernel\KernelInterface
27+ */
28+ private $ kernel ;
29+
30+ /**
31+ * @When /^I run the command "([^"]+)"$/
32+ */
33+ public function iRunTheCommand ($ command )
34+ {
35+ $ application = new Application ($ this ->kernel );
36+ $ application ->setAutoExit (false );
37+
38+ $ input = new ArrayInput (['command ' => $ command , '--env ' => 'behat ' ]);
39+
40+ $ output = new BufferedOutput ();
41+ $ application ->run ($ input , $ output );
42+
43+ $ content = $ output ->fetch ();
44+ }
45+
46+ /**
47+ * @Then /^the schema files are generated in "([^"]*)"$/
48+ */
49+ public function theSchemaFilesAreGeneratedIn ($ directory )
50+ {
51+ $ finder = new Finder ();
52+ Assert::assertFileExists ('app/config/graphql/ezplatform/Domain.types.yml ' );
53+ Assert::assertFileExists ('app/config/graphql/ezplatform/DomainContentMutation.types.yml ' );
54+ }
55+
56+ /**
57+ * @Given /^the schema has not been generated$/
58+ */
59+ public function theSchemaHasNotBeenGenerated ()
60+ {
61+ if (file_exists ('app/config/graphql/ezplatform ' )) {
62+ $ finder = new Finder ();
63+ $ fs = new Filesystem ();
64+ $ fs ->remove ($ finder ->in ('app/config/graphql/ezplatform ' )->files ());
65+ }
66+ }
67+
68+ /**
69+ * Sets Kernel instance.
70+ *
71+ * @param \Symfony\Component\HttpKernel\KernelInterface $kernel
72+ */
73+ public function setKernel (KernelInterface $ kernel )
74+ {
75+ $ this ->kernel = $ kernel ;
76+ }
77+ }
0 commit comments