We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 20 | abstract class AbstractQuerySecurityTest extends \PHPUnit_Framework_TestCase |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @param $max |
||
| 24 | * |
||
| 25 | * @return AbstractQuerySecurity |
||
| 26 | */ |
||
| 27 | abstract protected function createRule($max); |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param $max |
||
| 31 | * @param $count |
||
| 32 | * |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | abstract protected function getErrorMessage($max, $count); |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @expectedException \InvalidArgumentException |
||
| 39 | * @expectedExceptionMessage argument must be greater or equal to 0. |
||
| 40 | */ |
||
| 41 | public function testMaxQueryDepthMustBeGreaterOrEqualTo0() |
||
| 45 | |||
| 46 | protected function createFormattedError($max, $count, $locations = []) |
||
| 47 | { |
||
| 48 | return FormattedError::create($this->getErrorMessage($max, $count), $locations); |
||
| 49 | } |
||
| 50 | |||
| 51 | protected function assertDocumentValidator($queryString, $max, array $expectedErrors = []) |
||
| 52 | { |
||
| 53 | $errors = DocumentValidator::validate( |
||
| 54 | Schema::buildSchema(), |
||
| 55 | Parser::parse($queryString), |
||
| 56 | [$this->createRule($max)] |
||
| 57 | ); |
||
| 58 | |||
| 59 | $this->assertEquals($expectedErrors, array_map(['GraphQL\Error', 'formatError'], $errors), $queryString); |
||
| 60 | |||
| 61 | return $errors; |
||
| 62 | } |
||
| 63 | |||
| 64 | protected function assertIntrospectionQuery($maxExpected) |
||
| 70 | |||
| 71 | protected function assertIntrospectionTypeMetaFieldQuery($maxExpected) |
||
| 83 | |||
| 84 | protected function assertTypeNameMetaFieldQuery($maxExpected) |
||
| 96 | |||
| 97 | protected function assertMaxValue($query, $maxExpected) |
||
| 105 | } |
||
| 106 |