From 2d48b4e0442b96b5d075c819f53f47230e38046a Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 18:10:51 -0400 Subject: [PATCH 01/13] devops: Codecoverage configurations updated --- codeception.dist.yml | 2 +- phpunit.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codeception.dist.yml b/codeception.dist.yml index 5405279..a3dbd55 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -8,7 +8,7 @@ actor_suffix: Tester coverage: enabled: true include: - - src/TestCase/* + - src/* exclude: - src/TestCase/WPGraphQLUnitTestCase.php show_only_summary: false diff --git a/phpunit.xml b/phpunit.xml index 3fbdcb5..37dc0d0 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -23,9 +23,9 @@ - src/TestCase/WPGraphQLTestCommon.php - src/TestCase/WPGraphQLUnitTestCase.php + src/ + src/TestCase/WPGraphQLTestCase.php vendor/ local/ From c879875de5914aa7a52df8653bc21bf275912e3b Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 20:23:34 -0400 Subject: [PATCH 02/13] devops: Tests expanded --- .github/workflows/continous-integration.yml | 6 +- src/Constraint/QueryConstraint.php | 22 ++-- .../wpunit/QueryConstraintTest.php | 16 ++- .../wpunit/QueryErrorConstraintTest.php | 22 ++-- .../wpunit/QuerySuccessfulConstraintTest.php | 89 +++++++++++--- tests/phpunit/unit/test-queryconstraint.php | 20 +++- .../unit/test-queryerrorconstraint.php | 30 +++-- .../unit/test-querysuccessfulconstraint.php | 112 ++++++++++++++---- 8 files changed, 245 insertions(+), 72 deletions(-) diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml index 24fb8f9..9dc2f78 100644 --- a/.github/workflows/continous-integration.yml +++ b/.github/workflows/continous-integration.yml @@ -34,7 +34,7 @@ jobs: - name: Install WP PHPUnit Dependencies run: | - composer install --ignore-platform-reqs + composer install composer require wp-phpunit/wp-phpunit \ yoast/phpunit-polyfills \ phpunit/phpunit:^9.6 \ @@ -45,11 +45,11 @@ jobs: - name: Install WPBrowser Dependencies run: | - composer install --ignore-platform-reqs + composer install composer require codeception/module-asserts:* \ codeception/util-universalframework:* \ codeception/module-rest:* \ - lucatume/wp-browser:^3.1 --ignore-platform-reqs + lucatume/wp-browser:^3.1 - name: Run Codeception Tests w/ Docker. run: composer run-codeception -- -- --coverage --coverage-xml diff --git a/src/Constraint/QueryConstraint.php b/src/Constraint/QueryConstraint.php index 5486deb..a6e0bbd 100644 --- a/src/Constraint/QueryConstraint.php +++ b/src/Constraint/QueryConstraint.php @@ -86,9 +86,7 @@ protected function responseIsValid( $response, &$message = null ) { * Evaluates the response "data" against a validation rule. * * @param array $response GraphQL query response object - * @param array $expected_data Validation Rule. - * - * @throws Exception Invalid rule object provided for evaluation. + * @param array $expected_data Validation Rule.valid rule object provided for evaluation. * * @return bool */ @@ -96,7 +94,8 @@ protected function expectedDataFound( array $response, array $expected_data, str // Throw if "$expected_data" invalid. if ( empty( $expected_data['type'] ) ) { $this->logger->logData( [ 'INVALID_DATA_OBJECT' => $expected_data ] ); - throw new Exception( 'Invalid rule object provided for evaluation.' ); + $this->error_messages[] = "Invalid rule object provided for evaluation: \n\t " . json_encode( $expected_data, JSON_PRETTY_PRINT ); + return false; } // Deconstruct $expected_data. @@ -144,7 +143,7 @@ protected function expectedDataFound( array $response, array $expected_data, str $this->error_messages[] = sprintf( 'Expected data at path "%s" to be falsy value. "%s" Given', $full_path, - is_array( $actual_data ) ? json_encode( $actual_data, JSON_PRETTY_PRINT ) : $actual_data + is_array( $actual_data ) ? "\n\n" . json_encode( $actual_data, JSON_PRETTY_PRINT ) : $actual_data ); return false; @@ -159,7 +158,7 @@ protected function expectedDataFound( array $response, array $expected_data, str $this->error_messages[] = sprintf( 'Expected data at path "%s" to be falsy value. "%s" Given', $full_path, - is_array( $actual_data ) ? json_encode( $actual_data, JSON_PRETTY_PRINT ) : $actual_data + is_array( $actual_data ) ? "\n\n" .json_encode( $actual_data, JSON_PRETTY_PRINT ) : $actual_data ); return false; @@ -167,7 +166,7 @@ protected function expectedDataFound( array $response, array $expected_data, str $this->error_messages[] = sprintf( 'Expected data at path "%s" not to be falsy value. "%s" Given', $full_path, - is_array( $actual_data ) ? json_encode( $actual_data, JSON_PRETTY_PRINT ) : $actual_data + is_array( $actual_data ) ? "\n\n" .json_encode( $actual_data, JSON_PRETTY_PRINT ) : $actual_data ); return false; @@ -267,7 +266,8 @@ protected function expectedDataFound( array $response, array $expected_data, str return true; default: $this->logger->logData( ['INVALID_DATA_OBJECT', $expected_data ] ); - throw new Exception( 'Invalid data object provided for evaluation.' ); + $this->error_messages[] = "Invalid data object provided for evaluation. \n\t" . json_encode( $expected_data, JSON_PRETTY_PRINT ); + return false; } } @@ -369,7 +369,9 @@ function( $v ) { return false; default: - throw new Exception( 'Invalid data object provided for evaluation.' ); + $this->logger->logData( ['INVALID_DATA_OBJECT', $expected_data ] ); + $this->error_messages[] = "Invalid data object provided for evaluation. \n\t" . json_encode( $expected_data, JSON_PRETTY_PRINT ); + return false; } } @@ -572,7 +574,7 @@ public function matches($response): bool { } public function failureDescription($other): string { - return "GraphQL response failed validation: \n" . implode( "\n\t", $this->error_messages ); + return "GraphQL response failed validation: \n\n\t•" . implode( "\n\n\t•", $this->error_messages ); } /** diff --git a/tests/codeception/wpunit/QueryConstraintTest.php b/tests/codeception/wpunit/QueryConstraintTest.php index 4c7e1cf..5622227 100644 --- a/tests/codeception/wpunit/QueryConstraintTest.php +++ b/tests/codeception/wpunit/QueryConstraintTest.php @@ -65,4 +65,18 @@ public function testGraphQLResponseWithErrors() { $constraint = new QueryConstraint($this->logger); $this->assertTrue($constraint->matches($response)); } -} \ No newline at end of file + + public function testInvalidGraphQLResponse() { + $response1 = []; + $constraint = new QueryConstraint($this->logger); + $this->assertFalse($constraint->matches($response1)); + + $response2 = null; + $constraint = new QueryConstraint($this->logger); + $this->assertFalse($constraint->matches($response1)); + + $response3 = [ 'something' => [] ]; + $constraint = new QueryConstraint($this->logger); + $this->assertFalse($constraint->matches($response3)); + } +} diff --git a/tests/codeception/wpunit/QueryErrorConstraintTest.php b/tests/codeception/wpunit/QueryErrorConstraintTest.php index 047e0af..13d4493 100644 --- a/tests/codeception/wpunit/QueryErrorConstraintTest.php +++ b/tests/codeception/wpunit/QueryErrorConstraintTest.php @@ -127,13 +127,17 @@ public function testPassingValidationRules() { } public function testFailingValidationRules() { - // Register broken field - register_graphql_field( 'Post', 'invalidField', [ - 'type' => 'String', - 'resolve' => function() { - throw new \GraphQL\Error\UserError('Explosion!'); - } - ]); + // Register broken field. + register_graphql_field( + 'Post', + 'invalidField', + [ + 'type' => 'String', + 'resolve' => function() { + throw new \GraphQL\Error\UserError('Explosion!'); + }, + ] + ); // Create some posts. $this->factory()->post->create(); @@ -173,6 +177,10 @@ public function testFailingValidationRules() { 'type' => 'ERROR_PATH', 'path' => 'posts.nodes.#.id', ], + [ + 'type' => 'ERROR_INVALID', + 'path' => '', + ] ] ); $this->assertFalse($constraint->matches($response)); diff --git a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php index 97db334..b8e1c03 100644 --- a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php +++ b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php @@ -97,24 +97,34 @@ public function testPassingValidationRules() { $this->logger, [ [ - 'type' => 'NODE', - 'path' => 'posts.nodes', + 'type' => 'NODE', + 'path' => 'posts.nodes', 'expected_value' => [ [ - 'type' => 'FIELD', - 'path' => 'id', + 'type' => 'FIELD', + 'path' => 'id', 'expected_value' => 'codecept_field_value_not_null', ], [ - 'type' => 'FIELD', - 'path' => 'title', + 'type' => 'FIELD', + 'path' => 'id', + 'expected_value' => 'codecept_field_value_not_falsy', + ], + [ + 'type' => 'FIELD', + 'path' => 'title', 'expected_value' => 'hello world', ], [ - 'type' => 'FIELD', - 'path' => 'slug', + 'type' => 'FIELD', + 'path' => 'slug', 'expected_value' => 'test_post', ], + [ + 'type' => 'FIELD', + 'path' => 'nullField', + 'expected_value' => 'codecept_field_value_is_null', + ], ], 'expected_index' => null, ] @@ -133,6 +143,8 @@ public function testFailingValidationRules() { posts { nodes { id + databaseId + nullField } } } @@ -149,32 +161,75 @@ public function testFailingValidationRules() { [ 'type' => 'FIELD', 'path' => 'invalidNodePath', - 'expected_value' => 'phpunit_field_value_not_null', + 'expected_value' => 'codecept_field_value_not_null', + ], + [ + 'type' => 'FIELD', + 'path' => 'invalidNodePath', + 'expected_value' => 'codecept_field_value_not_falsy', ], [ 'type' => 'NODE', 'path' => 'posts.nodes', 'expected_value' => [ [ - 'type' => 'FIELD', - 'path' => 'invalidFieldPath', - 'expected_value' => 'phpunit_field_value_not_null' + 'type' => 'FIELD', + 'path' => 'invalidFieldPath', + 'expected_value' => 'codecept_field_value_not_null' ], ], 'expected_index' => null, ], [ - 'type' => 'NODE', - 'path' => 'posts.nodes', + 'type' => 'NODE', + 'path' => 'posts.nodes', 'expected_value' => [ [ - 'type' => 'FIELD', - 'path' => 'id', + 'type' => 'FIELD', + 'path' => 'id', 'expected_value' => 'invalidFieldValue' ], + [ + 'type' => 'FIELD', + 'path' => 'id', + 'expected_value' => 'codecept_field_value_is_null', + ], + [ + 'type' => 'FIELD', + 'path' => 'id', + 'expected_value' => 'codecept_field_value_is_falsy', + ], + [ + 'type' => 'FIELD', + 'path' => 'nullField', + 'expected_value' => 'codecept_field_value_not_null', + ], + [ + 'type' => 'FIELD', + 'path' => 'nullField', + 'expected_value' => 'codecept_field_value_not_falsy', + ], ], 'expected_index' => null, - ] + ], + [ + 'type' => '!NODE', + 'path' => 'posts.nodes', + 'expected_value' => [ + [ + 'type' => 'FIELD', + 'path' => 'databaseId', + 'expected_value' => 'post_id', + ], + ], + 'expected_index' => 0, + ], + [ + 'type' => 'INVALID_TYPE', + 'path' => '', + 'expected_value' => [], + ], + ['InvalidRuleObject'], ] ); $this->assertFalse($constraint->matches($response)); diff --git a/tests/phpunit/unit/test-queryconstraint.php b/tests/phpunit/unit/test-queryconstraint.php index e415641..122e443 100644 --- a/tests/phpunit/unit/test-queryconstraint.php +++ b/tests/phpunit/unit/test-queryconstraint.php @@ -17,7 +17,7 @@ public function tearDown(): void { WPGraphQL::clear_schema(); } - public function testGraphQLResponse() { + public function test_GraphQLResponse() { // Create some posts. $this->factory()->post->create_many(4); @@ -41,7 +41,7 @@ public function testGraphQLResponse() { $this->assertTrue($constraint->matches($response)); } - public function testGraphQLResponseWithErrors() { + public function test_GraphQLResponseWithErrors() { // Create some posts. $this->factory()->post->create_many(4); @@ -65,4 +65,18 @@ public function testGraphQLResponseWithErrors() { $constraint = new QueryConstraint($this->logger); $this->assertTrue($constraint->matches($response)); } -} \ No newline at end of file + + public function test_InvalidGraphQLResponse() { + $response1 = []; + $constraint = new QueryConstraint($this->logger); + $this->assertFalse($constraint->matches($response1)); + + $response2 = null; + $constraint = new QueryConstraint($this->logger); + $this->assertFalse($constraint->matches($response1)); + + $response3 = [ 'something' => [] ]; + $constraint = new QueryConstraint($this->logger); + $this->assertFalse($constraint->matches($response3)); + } +} diff --git a/tests/phpunit/unit/test-queryerrorconstraint.php b/tests/phpunit/unit/test-queryerrorconstraint.php index fcc84a0..e154062 100644 --- a/tests/phpunit/unit/test-queryerrorconstraint.php +++ b/tests/phpunit/unit/test-queryerrorconstraint.php @@ -17,7 +17,7 @@ public function tearDown(): void { WPGraphQL::clear_schema(); } - public function testGraphQLResponseWithErrors() { + public function test_GraphQLResponseWithErrors() { // Create some posts. $this->factory()->post->create_many(4); @@ -42,7 +42,7 @@ public function testGraphQLResponseWithErrors() { $this->assertTrue($constraint->matches($response)); } - public function testGraphQLResponseWithoutErrors() { + public function test_GraphQLResponseWithoutErrors() { // Create some posts. $this->factory()->post->create_many(4); @@ -66,14 +66,18 @@ public function testGraphQLResponseWithoutErrors() { $this->assertFalse($constraint->matches($response)); } - public function testPassingValidationRules() { - // Register broken field - register_graphql_field( 'Post', 'invalidField', [ - 'type' => 'String', - 'resolve' => function() { - throw new \GraphQL\Error\UserError('Explosion!'); - } - ]); + public function test_PassingValidationRules() { + // Register broken field. + register_graphql_field( + 'Post', + 'invalidField', + [ + 'type' => 'String', + 'resolve' => function() { + throw new \GraphQL\Error\UserError('Explosion!'); + }, + ] + ); // Create some posts. $this->factory()->post->create([ @@ -126,7 +130,7 @@ public function testPassingValidationRules() { $this->assertTrue($constraint->matches($response)); } - public function testFailingValidationRules() { + public function test_FailingValidationRules() { // Register broken field register_graphql_field( 'Post', 'invalidField', [ 'type' => 'String', @@ -173,6 +177,10 @@ public function testFailingValidationRules() { 'type' => 'ERROR_PATH', 'path' => 'posts.nodes.#.id', ], + [ + 'type' => 'ERROR_INVALID', + 'path' => '', + ] ] ); $this->assertFalse($constraint->matches($response)); diff --git a/tests/phpunit/unit/test-querysuccessfulconstraint.php b/tests/phpunit/unit/test-querysuccessfulconstraint.php index 3314fa8..4d8eab1 100644 --- a/tests/phpunit/unit/test-querysuccessfulconstraint.php +++ b/tests/phpunit/unit/test-querysuccessfulconstraint.php @@ -17,7 +17,7 @@ public function tearDown(): void { WPGraphQL::clear_schema(); } - public function testValidGraphQLResponse() { + public function test_ValidGraphQLResponse() { // Create some posts. $this->factory()->post->create_many(4); @@ -43,7 +43,7 @@ public function testValidGraphQLResponse() { $this->assertTrue($constraint->matches($response)); } - public function testInvalidGraphQLResponse() { + public function test_InvalidGraphQLResponse() { // Create some posts. $this->factory()->post->create_many(4); @@ -70,11 +70,19 @@ public function testInvalidGraphQLResponse() { $this->assertFalse($constraint->matches($response)); } - public function testPassingValidationRules() { + public function test_PassingValidationRules() { // Create some posts. $this->factory()->post->create( [ 'post_title' => 'hello world', 'post_name' => 'test_post' ] ); $this->factory()->post->create_many(4); + // Register null field + register_graphql_field( 'Post', 'nullField', [ + 'type' => 'String', + 'resolve' => function() { + return null; + } + ]); + // GraphQL query. $query = ' query { @@ -83,6 +91,7 @@ public function testPassingValidationRules() { id title slug + nullField } } } @@ -97,24 +106,34 @@ public function testPassingValidationRules() { $this->logger, [ [ - 'type' => 'NODE', - 'path' => 'posts.nodes', + 'type' => 'NODE', + 'path' => 'posts.nodes', 'expected_value' => [ [ - 'type' => 'FIELD', - 'path' => 'id', + 'type' => 'FIELD', + 'path' => 'id', 'expected_value' => 'phpunit_field_value_not_null', ], [ - 'type' => 'FIELD', - 'path' => 'title', + 'type' => 'FIELD', + 'path' => 'id', + 'expected_value' => 'phpunit_field_value_not_falsy', + ], + [ + 'type' => 'FIELD', + 'path' => 'title', 'expected_value' => 'hello world', ], [ - 'type' => 'FIELD', - 'path' => 'slug', + 'type' => 'FIELD', + 'path' => 'slug', 'expected_value' => 'test_post', ], + [ + 'type' => 'FIELD', + 'path' => 'nullField', + 'expected_value' => 'phpunit_field_value_is_null', + ], ], 'expected_index' => null, ] @@ -123,9 +142,17 @@ public function testPassingValidationRules() { $this->assertTrue($constraint->matches($response)); } - public function testFailingValidationRules() { + public function test_FailingValidationRules() { // Create some posts. - $this->factory()->post->create_many(5); + $post_id = $this->factory()->post->create( [ 'post_title' => 'hello world', 'post_name' => 'test_post' ] ); + + // Register null field + register_graphql_field( 'Post', 'nullField', [ + 'type' => 'String', + 'resolve' => function() { + return null; + } + ]); // GraphQL query. $query = ' @@ -133,6 +160,8 @@ public function testFailingValidationRules() { posts { nodes { id + databaseId + nullField } } } @@ -151,30 +180,73 @@ public function testFailingValidationRules() { 'path' => 'invalidNodePath', 'expected_value' => 'phpunit_field_value_not_null', ], + [ + 'type' => 'FIELD', + 'path' => 'invalidNodePath', + 'expected_value' => 'phpunit_field_value_not_falsy', + ], [ 'type' => 'NODE', 'path' => 'posts.nodes', 'expected_value' => [ [ - 'type' => 'FIELD', - 'path' => 'invalidFieldPath', + 'type' => 'FIELD', + 'path' => 'invalidFieldPath', 'expected_value' => 'phpunit_field_value_not_null' ], ], 'expected_index' => null, ], [ - 'type' => 'NODE', - 'path' => 'posts.nodes', + 'type' => 'NODE', + 'path' => 'posts.nodes', 'expected_value' => [ [ - 'type' => 'FIELD', - 'path' => 'id', + 'type' => 'FIELD', + 'path' => 'id', 'expected_value' => 'invalidFieldValue' ], + [ + 'type' => 'FIELD', + 'path' => 'id', + 'expected_value' => 'phpunit_field_value_is_null', + ], + [ + 'type' => 'FIELD', + 'path' => 'id', + 'expected_value' => 'phpunit_field_value_is_falsy', + ], + [ + 'type' => 'FIELD', + 'path' => 'nullField', + 'expected_value' => 'phpunit_field_value_not_null', + ], + [ + 'type' => 'FIELD', + 'path' => 'nullField', + 'expected_value' => 'phpunit_field_value_not_falsy', + ], ], 'expected_index' => null, - ] + ], + [ + 'type' => '!NODE', + 'path' => 'posts.nodes', + 'expected_value' => [ + [ + 'type' => 'FIELD', + 'path' => 'databaseId', + 'expected_value' => 'post_id', + ], + ], + 'expected_index' => 0, + ], + [ + 'type' => 'INVALID_TYPE', + 'path' => '', + 'expected_value' => [], + ], + ['InvalidRuleObject'], ] ); $this->assertFalse($constraint->matches($response)); From 54435f4a7a49ddf45432b6518857a6700327a264 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 20:27:20 -0400 Subject: [PATCH 03/13] devops: Respective logger classes added to the codecoverage ignore list --- codeception.dist.yml | 1 + phpunit.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/codeception.dist.yml b/codeception.dist.yml index a3dbd55..0af5afc 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -11,6 +11,7 @@ coverage: - src/* exclude: - src/TestCase/WPGraphQLUnitTestCase.php + - src/Logger/PHPUnitLogger.php show_only_summary: false extensions: enabled: diff --git a/phpunit.xml b/phpunit.xml index 37dc0d0..e6cedce 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -26,6 +26,7 @@ src/ src/TestCase/WPGraphQLTestCase.php + src/Logger/CodeceptLogger.php vendor/ local/ From b7b0d37cf1d00e3769048cda2892db528df24455 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 20:38:10 -0400 Subject: [PATCH 04/13] devops: PHP_VERSION now being used in Docker build --- .github/workflows/continous-integration.yml | 4 ++++ docker-compose.yml | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml index 9dc2f78..bce3812 100644 --- a/.github/workflows/continous-integration.yml +++ b/.github/workflows/continous-integration.yml @@ -41,6 +41,8 @@ jobs: wp-phpunit/wp-phpunit \ - name: Run PHPUnit Tests w/ Docker. + env: + PHP_VERSION: ${{ matrix.php }} run: composer run-phpunit -- -- --coverage-text - name: Install WPBrowser Dependencies @@ -52,6 +54,8 @@ jobs: lucatume/wp-browser:^3.1 - name: Run Codeception Tests w/ Docker. + env: + PHP_VERSION: ${{ matrix.php }} run: composer run-codeception -- -- --coverage --coverage-xml diff --git a/docker-compose.yml b/docker-compose.yml index 9191e12..2cb0395 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,9 +11,11 @@ services: MYSQL_PASSWORD: password wordpress: - image: wp-graphql/wordpress:${WORDPRESS_IMAGE_VERSION:-latest} + image: wp-graphql/wordpress:${WP_VERSION:-latest} build: context: ./docker + args: + PHP_VERSION: ${PHP_VERSION:-8.0} depends_on: - mysql - mysql_phpunit From 0cf1dc9319edb8af59dcba8b3c609a7a1a96c3b6 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 20:58:12 -0400 Subject: [PATCH 05/13] devops: More changes to the tests --- src/Constraint/QueryConstraint.php | 2 +- src/Constraint/QueryErrorConstraint.php | 2 +- src/Constraint/QuerySuccessfulConstraint.php | 2 +- src/Logger/CodeceptLogger.php | 2 +- src/Logger/Logger.php | 2 +- src/Logger/PHPUnitLogger.php | 2 +- src/Utils/Utils.php | 2 +- tests/codeception/wpunit/QueryConstraintTest.php | 14 +++++++++++++- .../wpunit/QueryErrorConstraintTest.php | 11 +++++++++++ .../wpunit/QuerySuccessfulConstraintTest.php | 11 +++++++++++ tests/phpunit/unit/test-queryconstraint.php | 14 +++++++++++++- tests/phpunit/unit/test-queryerrorconstraint.php | 12 ++++++++++++ .../unit/test-querysuccessfulconstraint.php | 11 +++++++++++ 13 files changed, 78 insertions(+), 9 deletions(-) diff --git a/src/Constraint/QueryConstraint.php b/src/Constraint/QueryConstraint.php index a6e0bbd..2776ff2 100644 --- a/src/Constraint/QueryConstraint.php +++ b/src/Constraint/QueryConstraint.php @@ -3,7 +3,7 @@ * QueryConstraint interface * * Defines shared logic for QueryConstraint classes. - * @since TBD + * @since v3.0.0 * @package Tests\WPGraphQL\Constraint */ diff --git a/src/Constraint/QueryErrorConstraint.php b/src/Constraint/QueryErrorConstraint.php index 7192b9e..48c8706 100644 --- a/src/Constraint/QueryErrorConstraint.php +++ b/src/Constraint/QueryErrorConstraint.php @@ -3,7 +3,7 @@ * QueryErrorConstraint * * Assertion validating successful WPGraphQL query response. - * @since TBD + * @since v3.0.0 * @package Tests\WPGraphQL\Constraint */ diff --git a/src/Constraint/QuerySuccessfulConstraint.php b/src/Constraint/QuerySuccessfulConstraint.php index 913cf34..98713d1 100644 --- a/src/Constraint/QuerySuccessfulConstraint.php +++ b/src/Constraint/QuerySuccessfulConstraint.php @@ -3,7 +3,7 @@ * QuerySuccessfulConstraint * * Assertion validating successful WPGraphQL query response. - * @since TBD + * @since v3.0.0 * @package Tests\WPGraphQL\Constraint */ diff --git a/src/Logger/CodeceptLogger.php b/src/Logger/CodeceptLogger.php index aaf2df5..f0da219 100644 --- a/src/Logger/CodeceptLogger.php +++ b/src/Logger/CodeceptLogger.php @@ -3,7 +3,7 @@ * CodeceptLogger * * Console logging for Codeception tests. - * @since TBD + * @since v3.0.0 * @package Tests\WPGraphQL\Logger */ namespace Tests\WPGraphQL\Logger; diff --git a/src/Logger/Logger.php b/src/Logger/Logger.php index 4af44d1..64bb608 100644 --- a/src/Logger/Logger.php +++ b/src/Logger/Logger.php @@ -3,7 +3,7 @@ * Logger interface * * Defines shared logic for Logger classes. - * @since TBD + * @since v3.0.0 * @package Tests\WPGraphQL\Logger */ diff --git a/src/Logger/PHPUnitLogger.php b/src/Logger/PHPUnitLogger.php index e697f22..1bc52b4 100644 --- a/src/Logger/PHPUnitLogger.php +++ b/src/Logger/PHPUnitLogger.php @@ -3,7 +3,7 @@ * PHPUnitLogger * * Console logging for PHPUnit tests. - * @since TBD + * @since v3.0.0 * @package Tests\WPGraphQL\Logger */ namespace Tests\WPGraphQL\Logger; diff --git a/src/Utils/Utils.php b/src/Utils/Utils.php index 6e4213a..afb1d3a 100644 --- a/src/Utils/Utils.php +++ b/src/Utils/Utils.php @@ -2,7 +2,7 @@ /** * Utils class * - * @since TBD + * @since v3.0.0 * @package Tests\WPGraphQL\Utils */ diff --git a/tests/codeception/wpunit/QueryConstraintTest.php b/tests/codeception/wpunit/QueryConstraintTest.php index 5622227..ebb4fc5 100644 --- a/tests/codeception/wpunit/QueryConstraintTest.php +++ b/tests/codeception/wpunit/QueryConstraintTest.php @@ -67,7 +67,7 @@ public function testGraphQLResponseWithErrors() { } public function testInvalidGraphQLResponse() { - $response1 = []; + $response1 = [4, 5, 6]; $constraint = new QueryConstraint($this->logger); $this->assertFalse($constraint->matches($response1)); @@ -79,4 +79,16 @@ public function testInvalidGraphQLResponse() { $constraint = new QueryConstraint($this->logger); $this->assertFalse($constraint->matches($response3)); } + + public function testFailureDescription() { + $constraint = new QueryConstraint($this->logger); + $response = [4, 5, 6]; + $this->assertFalse($constraint->matches($response3)); + $this->assertEquals("GraphQL response failed validation: \n\n\t• The GraphQL query response must be provided as an associative array.", $constraint->failureDescription($response)); + } + + public function testToString() { + $constraint = new QueryErrorConstraint($this->logger); + $this->assertEquals('is a valid WPGraphQL response', $constraint->toString()); + } } diff --git a/tests/codeception/wpunit/QueryErrorConstraintTest.php b/tests/codeception/wpunit/QueryErrorConstraintTest.php index 13d4493..2ed7dd7 100644 --- a/tests/codeception/wpunit/QueryErrorConstraintTest.php +++ b/tests/codeception/wpunit/QueryErrorConstraintTest.php @@ -185,4 +185,15 @@ public function testFailingValidationRules() { ); $this->assertFalse($constraint->matches($response)); } + + public function testInvalidGraphQLResponse() { + $response1 = [4, 5, 6]; + $constraint = new QueryErrorConstraint($this->logger); + $this->assertFalse($constraint->matches($response1)); + } + + public function testToString() { + $constraint = new QueryErrorConstraint($this->logger); + $this->assertEquals('is a WPGraphQL query response with errors', $constraint->toString()); + } } \ No newline at end of file diff --git a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php index b8e1c03..84bc24c 100644 --- a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php +++ b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php @@ -234,4 +234,15 @@ public function testFailingValidationRules() { ); $this->assertFalse($constraint->matches($response)); } + + public function testBadGraphQLResponse() { + $response1 = [4, 5, 6]; + $constraint = new QueryErrorConstraint($this->logger); + $this->assertFalse($constraint->matches($response1)); + } + + public function testToString() { + $constraint = new QueryErrorConstraint($this->logger); + $this->assertEquals('is a successful WPGraphQL response with no errors.', $constraint->toString()); + } } \ No newline at end of file diff --git a/tests/phpunit/unit/test-queryconstraint.php b/tests/phpunit/unit/test-queryconstraint.php index 122e443..644a4ba 100644 --- a/tests/phpunit/unit/test-queryconstraint.php +++ b/tests/phpunit/unit/test-queryconstraint.php @@ -67,7 +67,7 @@ public function test_GraphQLResponseWithErrors() { } public function test_InvalidGraphQLResponse() { - $response1 = []; + $response1 = [4, 5, 6]; $constraint = new QueryConstraint($this->logger); $this->assertFalse($constraint->matches($response1)); @@ -79,4 +79,16 @@ public function test_InvalidGraphQLResponse() { $constraint = new QueryConstraint($this->logger); $this->assertFalse($constraint->matches($response3)); } + + public function test_FailureDescription() { + $constraint = new QueryConstraint($this->logger); + $response = [4, 5, 6]; + $this->assertFalse($constraint->matches($response3)); + $this->assertEquals("GraphQL response failed validation: \n\n\t• The GraphQL query response must be provided as an associative array.", $constraint->failureDescription($response)); + } + + public function test_ToString() { + $constraint = new QueryErrorConstraint($this->logger); + $this->assertEquals('is a valid WPGraphQL response', $constraint->toString()); + } } diff --git a/tests/phpunit/unit/test-queryerrorconstraint.php b/tests/phpunit/unit/test-queryerrorconstraint.php index e154062..c951d10 100644 --- a/tests/phpunit/unit/test-queryerrorconstraint.php +++ b/tests/phpunit/unit/test-queryerrorconstraint.php @@ -177,6 +177,7 @@ public function test_FailingValidationRules() { 'type' => 'ERROR_PATH', 'path' => 'posts.nodes.#.id', ], + ['InvalidRuleObject'], [ 'type' => 'ERROR_INVALID', 'path' => '', @@ -185,4 +186,15 @@ public function test_FailingValidationRules() { ); $this->assertFalse($constraint->matches($response)); } + + public function test_InvalidGraphQLResponse() { + $response1 = [4, 5, 6]; + $constraint = new QueryErrorConstraint($this->logger); + $this->assertFalse($constraint->matches($response1)); + } + + public function test_ToString() { + $constraint = new QueryErrorConstraint($this->logger); + $this->assertEquals('is a WPGraphQL query response with errors', $constraint->toString()); + } } \ No newline at end of file diff --git a/tests/phpunit/unit/test-querysuccessfulconstraint.php b/tests/phpunit/unit/test-querysuccessfulconstraint.php index 4d8eab1..a933154 100644 --- a/tests/phpunit/unit/test-querysuccessfulconstraint.php +++ b/tests/phpunit/unit/test-querysuccessfulconstraint.php @@ -251,4 +251,15 @@ public function test_FailingValidationRules() { ); $this->assertFalse($constraint->matches($response)); } + + public function test_BadGraphQLResponse() { + $response1 = [4, 5, 6]; + $constraint = new QuerySuccessfulConstraint($this->logger); + $this->assertFalse($constraint->matches($response1)); + } + + public function test_ToString() { + $constraint = new QueryErrorConstraint($this->logger); + $this->assertEquals('is a successful WPGraphQL response with no errors.', $constraint->toString()); + } } \ No newline at end of file From c3ebdccb4966b515a75d0d7e91432563bffc7a42 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 21:01:34 -0400 Subject: [PATCH 06/13] devops: tests fixed --- tests/codeception/wpunit/QueryConstraintTest.php | 2 +- tests/codeception/wpunit/QuerySuccessfulConstraintTest.php | 4 ++-- tests/phpunit/unit/test-queryconstraint.php | 2 +- tests/phpunit/unit/test-querysuccessfulconstraint.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/codeception/wpunit/QueryConstraintTest.php b/tests/codeception/wpunit/QueryConstraintTest.php index ebb4fc5..57265d5 100644 --- a/tests/codeception/wpunit/QueryConstraintTest.php +++ b/tests/codeception/wpunit/QueryConstraintTest.php @@ -88,7 +88,7 @@ public function testFailureDescription() { } public function testToString() { - $constraint = new QueryErrorConstraint($this->logger); + $constraint = new QueryConstraint($this->logger); $this->assertEquals('is a valid WPGraphQL response', $constraint->toString()); } } diff --git a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php index 84bc24c..8292445 100644 --- a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php +++ b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php @@ -237,12 +237,12 @@ public function testFailingValidationRules() { public function testBadGraphQLResponse() { $response1 = [4, 5, 6]; - $constraint = new QueryErrorConstraint($this->logger); + $constraint = new QuerySuccessfulConstraint($this->logger); $this->assertFalse($constraint->matches($response1)); } public function testToString() { - $constraint = new QueryErrorConstraint($this->logger); + $constraint = new QuerySuccessfulConstraint($this->logger); $this->assertEquals('is a successful WPGraphQL response with no errors.', $constraint->toString()); } } \ No newline at end of file diff --git a/tests/phpunit/unit/test-queryconstraint.php b/tests/phpunit/unit/test-queryconstraint.php index 644a4ba..b616ca3 100644 --- a/tests/phpunit/unit/test-queryconstraint.php +++ b/tests/phpunit/unit/test-queryconstraint.php @@ -88,7 +88,7 @@ public function test_FailureDescription() { } public function test_ToString() { - $constraint = new QueryErrorConstraint($this->logger); + $constraint = new QueryConstraint($this->logger); $this->assertEquals('is a valid WPGraphQL response', $constraint->toString()); } } diff --git a/tests/phpunit/unit/test-querysuccessfulconstraint.php b/tests/phpunit/unit/test-querysuccessfulconstraint.php index a933154..3804082 100644 --- a/tests/phpunit/unit/test-querysuccessfulconstraint.php +++ b/tests/phpunit/unit/test-querysuccessfulconstraint.php @@ -259,7 +259,7 @@ public function test_BadGraphQLResponse() { } public function test_ToString() { - $constraint = new QueryErrorConstraint($this->logger); + $constraint = new QuerySuccessfulConstraint($this->logger); $this->assertEquals('is a successful WPGraphQL response with no errors.', $constraint->toString()); } } \ No newline at end of file From cf285c133caefab698f5dc63cc0e914a1cf47021 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 21:05:03 -0400 Subject: [PATCH 07/13] devops: tests fixed --- tests/codeception/wpunit/QueryConstraintTest.php | 2 +- tests/codeception/wpunit/QueryErrorConstraintTest.php | 4 ++-- tests/codeception/wpunit/QuerySuccessfulConstraintTest.php | 4 ++-- tests/phpunit/unit/test-queryconstraint.php | 2 +- tests/phpunit/unit/test-queryerrorconstraint.php | 4 ++-- tests/phpunit/unit/test-querysuccessfulconstraint.php | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/codeception/wpunit/QueryConstraintTest.php b/tests/codeception/wpunit/QueryConstraintTest.php index 57265d5..d5b6104 100644 --- a/tests/codeception/wpunit/QueryConstraintTest.php +++ b/tests/codeception/wpunit/QueryConstraintTest.php @@ -83,7 +83,7 @@ public function testInvalidGraphQLResponse() { public function testFailureDescription() { $constraint = new QueryConstraint($this->logger); $response = [4, 5, 6]; - $this->assertFalse($constraint->matches($response3)); + $this->assertFalse($constraint->matches($response)); $this->assertEquals("GraphQL response failed validation: \n\n\t• The GraphQL query response must be provided as an associative array.", $constraint->failureDescription($response)); } diff --git a/tests/codeception/wpunit/QueryErrorConstraintTest.php b/tests/codeception/wpunit/QueryErrorConstraintTest.php index 2ed7dd7..1f526ef 100644 --- a/tests/codeception/wpunit/QueryErrorConstraintTest.php +++ b/tests/codeception/wpunit/QueryErrorConstraintTest.php @@ -187,9 +187,9 @@ public function testFailingValidationRules() { } public function testInvalidGraphQLResponse() { - $response1 = [4, 5, 6]; + $response = [4, 5, 6]; $constraint = new QueryErrorConstraint($this->logger); - $this->assertFalse($constraint->matches($response1)); + $this->assertFalse($constraint->matches($response)); } public function testToString() { diff --git a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php index 8292445..f8662a6 100644 --- a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php +++ b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php @@ -236,9 +236,9 @@ public function testFailingValidationRules() { } public function testBadGraphQLResponse() { - $response1 = [4, 5, 6]; + $response = [4, 5, 6]; $constraint = new QuerySuccessfulConstraint($this->logger); - $this->assertFalse($constraint->matches($response1)); + $this->assertFalse($constraint->matches($response)); } public function testToString() { diff --git a/tests/phpunit/unit/test-queryconstraint.php b/tests/phpunit/unit/test-queryconstraint.php index b616ca3..56355bb 100644 --- a/tests/phpunit/unit/test-queryconstraint.php +++ b/tests/phpunit/unit/test-queryconstraint.php @@ -83,7 +83,7 @@ public function test_InvalidGraphQLResponse() { public function test_FailureDescription() { $constraint = new QueryConstraint($this->logger); $response = [4, 5, 6]; - $this->assertFalse($constraint->matches($response3)); + $this->assertFalse($constraint->matches($response)); $this->assertEquals("GraphQL response failed validation: \n\n\t• The GraphQL query response must be provided as an associative array.", $constraint->failureDescription($response)); } diff --git a/tests/phpunit/unit/test-queryerrorconstraint.php b/tests/phpunit/unit/test-queryerrorconstraint.php index c951d10..0cf966d 100644 --- a/tests/phpunit/unit/test-queryerrorconstraint.php +++ b/tests/phpunit/unit/test-queryerrorconstraint.php @@ -188,9 +188,9 @@ public function test_FailingValidationRules() { } public function test_InvalidGraphQLResponse() { - $response1 = [4, 5, 6]; + $response = [4, 5, 6]; $constraint = new QueryErrorConstraint($this->logger); - $this->assertFalse($constraint->matches($response1)); + $this->assertFalse($constraint->matches($response)); } public function test_ToString() { diff --git a/tests/phpunit/unit/test-querysuccessfulconstraint.php b/tests/phpunit/unit/test-querysuccessfulconstraint.php index 3804082..ccc49e4 100644 --- a/tests/phpunit/unit/test-querysuccessfulconstraint.php +++ b/tests/phpunit/unit/test-querysuccessfulconstraint.php @@ -253,9 +253,9 @@ public function test_FailingValidationRules() { } public function test_BadGraphQLResponse() { - $response1 = [4, 5, 6]; + $response = [4, 5, 6]; $constraint = new QuerySuccessfulConstraint($this->logger); - $this->assertFalse($constraint->matches($response1)); + $this->assertFalse($constraint->matches($response)); } public function test_ToString() { From 05fac4ea5a41259deec7de972ace89c6a1d4d8ef Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 21:07:50 -0400 Subject: [PATCH 08/13] fix: QueryConstraint::$logger scope changed from "private" to "protected" --- src/Constraint/QueryConstraint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Constraint/QueryConstraint.php b/src/Constraint/QueryConstraint.php index 2776ff2..fa8276a 100644 --- a/src/Constraint/QueryConstraint.php +++ b/src/Constraint/QueryConstraint.php @@ -22,7 +22,7 @@ class QueryConstraint extends Constraint { * * @var PHPUnitLogger|CodeceptLogger */ - private $logger; + protected $logger; /** * Stores the validation steps for the assertion. From 7af1b50141330320e81473d0278b418ddc4d5498 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 21:10:58 -0400 Subject: [PATCH 09/13] chore: space added to error print out --- src/Constraint/QueryConstraint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Constraint/QueryConstraint.php b/src/Constraint/QueryConstraint.php index fa8276a..65ab278 100644 --- a/src/Constraint/QueryConstraint.php +++ b/src/Constraint/QueryConstraint.php @@ -574,7 +574,7 @@ public function matches($response): bool { } public function failureDescription($other): string { - return "GraphQL response failed validation: \n\n\t•" . implode( "\n\n\t•", $this->error_messages ); + return "GraphQL response failed validation: \n\n\t• " . implode( "\n\n\t• ", $this->error_messages ); } /** From 650096560f9ffaf3443cf7baea728fa59badda93 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 21:16:28 -0400 Subject: [PATCH 10/13] devops: tests updated --- src/Constraint/QueryErrorConstraint.php | 2 +- tests/codeception/wpunit/QueryErrorConstraintTest.php | 1 + tests/phpunit/unit/test-queryerrorconstraint.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Constraint/QueryErrorConstraint.php b/src/Constraint/QueryErrorConstraint.php index 48c8706..b303b56 100644 --- a/src/Constraint/QueryErrorConstraint.php +++ b/src/Constraint/QueryErrorConstraint.php @@ -38,7 +38,7 @@ public function matches($response): bool { if ( empty( $expected_data['type'] ) ) { $this->logger->logData( array( 'INVALID_DATA_OBJECT' => $expected_data ) ); $this->error_messages[] = 'Invalid data object provided for evaluation.'; - return false; + continue; } if ( str_starts_with( $expected_data['type'], 'ERROR_' ) ) { diff --git a/tests/codeception/wpunit/QueryErrorConstraintTest.php b/tests/codeception/wpunit/QueryErrorConstraintTest.php index 1f526ef..4f1cf18 100644 --- a/tests/codeception/wpunit/QueryErrorConstraintTest.php +++ b/tests/codeception/wpunit/QueryErrorConstraintTest.php @@ -163,6 +163,7 @@ public function testFailingValidationRules() { $constraint = new QueryErrorConstraint( $this->logger, [ + ['InvalidRuleObject'], [ 'type' => 'FIELD', 'path' => 'posts.nodes.#.content', diff --git a/tests/phpunit/unit/test-queryerrorconstraint.php b/tests/phpunit/unit/test-queryerrorconstraint.php index 0cf966d..65e5b9a 100644 --- a/tests/phpunit/unit/test-queryerrorconstraint.php +++ b/tests/phpunit/unit/test-queryerrorconstraint.php @@ -163,6 +163,7 @@ public function test_FailingValidationRules() { $constraint = new QueryErrorConstraint( $this->logger, [ + ['InvalidRuleObject'], [ 'type' => 'FIELD', 'path' => 'posts.nodes.#.content', @@ -177,7 +178,6 @@ public function test_FailingValidationRules() { 'type' => 'ERROR_PATH', 'path' => 'posts.nodes.#.id', ], - ['InvalidRuleObject'], [ 'type' => 'ERROR_INVALID', 'path' => '', From 38be5fbdeeddec8e0f5e48249d9c56bc24f8f288 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 21:19:39 -0400 Subject: [PATCH 11/13] refactor: responseIsValid refactored slightly --- src/Constraint/QueryConstraint.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Constraint/QueryConstraint.php b/src/Constraint/QueryConstraint.php index 65ab278..cc7a9d0 100644 --- a/src/Constraint/QueryConstraint.php +++ b/src/Constraint/QueryConstraint.php @@ -64,13 +64,13 @@ public function __construct($logger, array $expected = []) { * @return bool */ protected function responseIsValid( $response, &$message = null ) { - if ( array_keys( $response ) === range( 0, count( $response ) - 1 ) ) { - $this->error_messages[] = 'The GraphQL query response must be provided as an associative array.'; + if ( empty( $response ) ) { + $this->error_messages[] = 'GraphQL query response is invalid.'; return false; } - if ( empty( $response ) ) { - $this->error_messages[] = 'GraphQL query response is empty.'; + if ( array_keys( $response ) === range( 0, count( $response ) - 1 ) ) { + $this->error_messages[] = 'The GraphQL query response must be provided as an associative array.'; return false; } From 5f4f0c7edfe6308a75212fcd01ccf40b59a2b7bb Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 21:23:04 -0400 Subject: [PATCH 12/13] devops: tests updated --- tests/phpunit/unit/test-queryconstraint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/unit/test-queryconstraint.php b/tests/phpunit/unit/test-queryconstraint.php index 56355bb..151ed3f 100644 --- a/tests/phpunit/unit/test-queryconstraint.php +++ b/tests/phpunit/unit/test-queryconstraint.php @@ -73,7 +73,7 @@ public function test_InvalidGraphQLResponse() { $response2 = null; $constraint = new QueryConstraint($this->logger); - $this->assertFalse($constraint->matches($response1)); + $this->assertFalse($constraint->matches($response2)); $response3 = [ 'something' => [] ]; $constraint = new QueryConstraint($this->logger); From 72511899506121c177b27de24d3d64176b0e6270 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 2 May 2024 21:24:00 -0400 Subject: [PATCH 13/13] devops: tests updated --- tests/codeception/wpunit/QuerySuccessfulConstraintTest.php | 2 +- tests/phpunit/unit/test-querysuccessfulconstraint.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php index f8662a6..a123b25 100644 --- a/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php +++ b/tests/codeception/wpunit/QuerySuccessfulConstraintTest.php @@ -158,6 +158,7 @@ public function testFailingValidationRules() { $constraint = new QuerySuccessfulConstraint( $this->logger, [ + ['InvalidRuleObject'], [ 'type' => 'FIELD', 'path' => 'invalidNodePath', @@ -229,7 +230,6 @@ public function testFailingValidationRules() { 'path' => '', 'expected_value' => [], ], - ['InvalidRuleObject'], ] ); $this->assertFalse($constraint->matches($response)); diff --git a/tests/phpunit/unit/test-querysuccessfulconstraint.php b/tests/phpunit/unit/test-querysuccessfulconstraint.php index ccc49e4..c64343d 100644 --- a/tests/phpunit/unit/test-querysuccessfulconstraint.php +++ b/tests/phpunit/unit/test-querysuccessfulconstraint.php @@ -175,6 +175,7 @@ public function test_FailingValidationRules() { $constraint = new QuerySuccessfulConstraint( $this->logger, [ + ['InvalidRuleObject'], [ 'type' => 'FIELD', 'path' => 'invalidNodePath', @@ -246,7 +247,6 @@ public function test_FailingValidationRules() { 'path' => '', 'expected_value' => [], ], - ['InvalidRuleObject'], ] ); $this->assertFalse($constraint->matches($response));