We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 14 | abstract class TestCase extends WebTestCase |
||
| 15 | { |
||
| 16 | const USER_RYAN = 'ryan'; |
||
| 17 | const USER_ADMIN = 'admin'; |
||
| 18 | const ANONYMOUS_USER = null; |
||
| 19 | const DEFAULT_PASSWORD = '123'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * {@inheritdoc} |
||
| 23 | */ |
||
| 24 | protected static function getKernelClass() |
||
| 25 | { |
||
| 26 | return TestKernel::class; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * {@inheritdoc} |
||
| 31 | */ |
||
| 32 | protected static function createKernel(array $options = []) |
||
| 33 | { |
||
| 34 | if (null === static::$class) { |
||
| 35 | static::$class = static::getKernelClass(); |
||
| 36 | } |
||
| 37 | |||
| 38 | $options['test_case'] = isset($options['test_case']) ? $options['test_case'] : null; |
||
| 39 | |||
| 40 | $env = isset($options['environment']) ? $options['environment'] : 'test'.strtolower($options['test_case']); |
||
| 41 | $debug = isset($options['debug']) ? $options['debug'] : true; |
||
| 42 | |||
| 43 | return new static::$class($env, $debug, $options['test_case']); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritdoc} |
||
| 48 | */ |
||
| 49 | public static function setUpBeforeClass() |
||
| 50 | { |
||
| 51 | $fs = new Filesystem(); |
||
| 52 | $fs->remove(sys_get_temp_dir().'/OverblogGraphQLBundle/'); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * {@inheritdoc} |
||
| 57 | */ |
||
| 58 | protected function tearDown() |
||
| 59 | { |
||
| 60 | static::$kernel = null; |
||
| 61 | } |
||
| 62 | |||
| 63 | protected static function executeGraphQLRequest($query, $rootValue = [], $throwException = false) |
||
| 64 | { |
||
| 65 | $request = new Request(); |
||
| 66 | $request->query->set('query', $query); |
||
| 67 | |||
| 68 | $req = static::getContainer()->get('overblog_graphql.request_parser')->parse($request); |
||
| 69 | static::getContainer()->get('error_handler_listener')->setThrowException($throwException); |
||
| 70 | $res = static::getContainer()->get('overblog_graphql.request_executor')->execute(null, $req, $rootValue); |
||
| 71 | |||
| 72 | return $res->toArray(); |
||
| 73 | } |
||
| 74 | |||
| 75 | protected static function assertGraphQL($query, array $expectedData = null, array $expectedErrors = null, $rootValue = []) |
||
| 91 | |||
| 92 | protected static function getContainer() |
||
| 96 | |||
| 97 | protected static function query($query, $username, $testCase, $password = self::DEFAULT_PASSWORD) |
||
| 104 | |||
| 105 | protected static function createClientAuthenticated($username, $testCase, $password = self::DEFAULT_PASSWORD) |
||
| 118 | |||
| 119 | protected static function assertResponse($query, array $expected, $username, $testCase, $password = self::DEFAULT_PASSWORD) |
||
| 120 | { |
||
| 121 | $client = self::createClientAuthenticated($username, $testCase, $password); |
||
| 122 | $result = self::sendRequest($client, $query); |
||
| 123 | |||
| 128 | |||
| 129 | protected static function sendRequest(Client $client, $query, $isDecoded = false) |
||
| 136 | } |
||
| 137 |