-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bertrand Dunogier
committed
Jul 1, 2019
1 parent
61d8adf
commit bb70805
Showing
6 changed files
with
173 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
# This file is meant to be imported from ezplatform's behat.yml.dist. | ||
# All path are relative to the root ezplatform directory. | ||
default: {} | ||
default: | ||
autoload: | ||
- '%paths.base%/vendor/ezsystems/ezplatform-graphql/features/bootstrap/' | ||
|
||
graphql: | ||
suites: | ||
graphql: | ||
autoload: | ||
- '%paths.base%/vendor/ezsystems/ezplatform-graphql/features/bootstrap/' | ||
paths: | ||
- '%paths.base%/vendor/ezsystems/ezplatform-graphql/features/Generator.feature' | ||
- '%paths.base%/vendor/ezsystems/ezplatform-graphql/features/Generator.feature' | ||
contexts: | ||
- GraphQLContext | ||
- GeneratorContext | ||
- ConfigurationContext | ||
- CacheContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\Assert; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\BufferedOutput; | ||
use Symfony\Component\Finder\Finder; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
use Symfony\Component\Process\PhpExecutableFinder; | ||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
|
||
class CacheContext implements \Behat\Symfony2Extension\Context\KernelAwareContext | ||
{ | ||
/** | ||
* @var \Symfony\Component\HttpKernel\KernelInterface | ||
*/ | ||
private $kernel; | ||
|
||
/** | ||
* Sets Kernel instance. | ||
* | ||
* @param \Symfony\Component\HttpKernel\KernelInterface $kernel | ||
*/ | ||
public function setKernel(KernelInterface $kernel) | ||
{ | ||
$this->kernel = $kernel; | ||
} | ||
|
||
/** | ||
* @Given /^I clear the cache$/ | ||
*/ | ||
public function iClearTheCache() | ||
{ | ||
$application = new \Symfony\Bundle\FrameworkBundle\Console\Application($this->kernel); | ||
$application->setAutoExit(false); | ||
|
||
$input = new ArrayInput(['command' => 'cache:clear', '--env' => 'behat']); | ||
|
||
// You can use NullOutput() if you don't need the output | ||
$output = new BufferedOutput(); | ||
Assert::assertEquals(0, $application->run($input, $output)); | ||
$content = $output->fetch(); | ||
$this->kernel->shutdown(); | ||
$this->kernel->boot(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\Assert; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\BufferedOutput; | ||
use Symfony\Component\Finder\Finder; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
use Symfony\Component\Process\PhpExecutableFinder; | ||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
|
||
class ConfigurationContext implements \Behat\Symfony2Extension\Context\KernelAwareContext | ||
{ | ||
/** | ||
* @var \Symfony\Component\HttpKernel\KernelInterface | ||
*/ | ||
private $kernel; | ||
|
||
/** | ||
* Sets Kernel instance. | ||
* | ||
* @param \Symfony\Component\HttpKernel\KernelInterface $kernel | ||
*/ | ||
public function setKernel(KernelInterface $kernel) | ||
{ | ||
$this->kernel = $kernel; | ||
} | ||
|
||
/** | ||
* @Given /^the GraphQL extension is configured to use that schema$/ | ||
*/ | ||
public function theGraphQLExtensionIsConfiguredToUseThatSchema() | ||
{ | ||
$container = $this->kernel->getContainer(); | ||
$executor = $container->get('overblog_graphql.request_executor'); | ||
$schema = $executor->getSchema('default'); | ||
Assert::assertEquals('Domain', (string)$schema->getQueryType()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,75 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\Assert; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\BufferedOutput; | ||
use Symfony\Component\Finder\Finder; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
use Symfony\Component\Process\PhpExecutableFinder; | ||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
|
||
class GeneratorContext | ||
class GeneratorContext implements \Behat\Symfony2Extension\Context\KernelAwareContext | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $scriptOutput; | ||
|
||
/** | ||
* @var \Symfony\Component\HttpKernel\KernelInterface | ||
*/ | ||
private $kernel; | ||
|
||
/** | ||
* @When /^I run the command "([^"]+)"$/ | ||
*/ | ||
public function iRunTheCommand($command) | ||
{ | ||
$application = new Application($this->kernel); | ||
$application->setAutoExit(false); | ||
|
||
$input = new ArrayInput(['command' => $command, '--env' => 'behat']); | ||
|
||
$output = new BufferedOutput(); | ||
$application->run($input, $output); | ||
|
||
$content = $output->fetch(); | ||
} | ||
|
||
/** | ||
* @Then /^the schema files are generated in "([^"]*)"$/ | ||
*/ | ||
public function theSchemaFilesAreGeneratedIn($directory) | ||
{ | ||
$finder = new Finder(); | ||
Assert::assertFileExists('app/config/graphql/ezplatform/Domain.types.yml'); | ||
Assert::assertFileExists('app/config/graphql/ezplatform/DomainContentMutation.types.yml'); | ||
} | ||
|
||
/** | ||
* @Given /^the schema has not been generated$/ | ||
*/ | ||
public function theSchemaHasNotBeenGenerated() | ||
{ | ||
$finder = new Finder(); | ||
$fs = new Filesystem(); | ||
$fs->remove($finder->in('app/config/graphql/ezplatform')->files()); | ||
} | ||
|
||
/** | ||
* Sets Kernel instance. | ||
* | ||
* @param \Symfony\Component\HttpKernel\KernelInterface $kernel | ||
*/ | ||
public function setKernel(KernelInterface $kernel) | ||
{ | ||
$this->kernel = $kernel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters