From 8d2b2c543bc6683f46cd18ba64d147e987d08e41 Mon Sep 17 00:00:00 2001 From: Thijs van der heijden Date: Wed, 4 Dec 2024 14:37:45 +0100 Subject: [PATCH 1/2] Creates integration test for the Endpoints_Repository. --- .../Endpoints/Endpoints_Repository_Test.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/WP/Dashboard/Application/Endpoints/Endpoints_Repository_Test.php diff --git a/tests/WP/Dashboard/Application/Endpoints/Endpoints_Repository_Test.php b/tests/WP/Dashboard/Application/Endpoints/Endpoints_Repository_Test.php new file mode 100644 index 00000000000..645ce001844 --- /dev/null +++ b/tests/WP/Dashboard/Application/Endpoints/Endpoints_Repository_Test.php @@ -0,0 +1,66 @@ + $expected_list Expected url list. + * + * @return void + */ + public function test_get_all_endpoints( array $endpoints, array $expected_list ) { + $instance = new Endpoints_Repository( ...$endpoints ); + + self::assertEquals( $expected_list, $instance->get_all_endpoints()->to_array() ); + } + + /** + * Data provider for test_get_all_endpoints. + * + * @return array>> + */ + public static function data_get_all_endpoints() { + $readability_endpoint = new Readability_Scores_Endpoint(); + $seo_scores_endpoint = new SEO_Scores_Endpoint(); + + return [ + 'Seo and Readability endpoint' => [ + 'endpoints' => [ $readability_endpoint, $seo_scores_endpoint ], + 'expected_list' => [ + 'readabilityScores' => 'http://example.org/index.php?rest_route=/yoast/v1/readability_scores', + 'seoScores' => 'http://example.org/index.php?rest_route=/yoast/v1/seo_scores', + ], + ], + 'Seo endpoint' => [ + 'endpoints' => [ $seo_scores_endpoint ], + 'expected_list' => [ + + 'seoScores' => 'http://example.org/index.php?rest_route=/yoast/v1/seo_scores', + ], + ], + 'no endpoints' => [ + 'endpoints' => [], + 'expected_list' => [], + ], + ]; + } +} From 4608bf318129b635cd1bd4d3657036711d202a3d Mon Sep 17 00:00:00 2001 From: Thijs van der heijden Date: Thu, 5 Dec 2024 14:50:15 +0100 Subject: [PATCH 2/2] update @covers --- .../Application/Endpoints/Endpoints_Repository_Test.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/WP/Dashboard/Application/Endpoints/Endpoints_Repository_Test.php b/tests/WP/Dashboard/Application/Endpoints/Endpoints_Repository_Test.php index 645ce001844..f2880125cf3 100644 --- a/tests/WP/Dashboard/Application/Endpoints/Endpoints_Repository_Test.php +++ b/tests/WP/Dashboard/Application/Endpoints/Endpoints_Repository_Test.php @@ -11,15 +11,13 @@ /** * Integration Test Class for Yoast\WP\SEO\Dashboard\Application\Taxonomies\Endpoints_Repository. * - * @coversDefaultClass Yoast\WP\SEO\Dashboard\Application\Endpoints\Endpoints_Repository + * @covers Yoast\WP\SEO\Dashboard\Application\Endpoints\Endpoints_Repository::get_all_endpoints */ final class Endpoints_Repository_Test extends TestCase { /** * Tests if both endpoints make it into the endpoint list with the needed data * - * @covers ::get_all_endpoints - * * @dataProvider data_get_all_endpoints * * @param Endpoint_Interface[] $endpoints List of possible endpoints.