From 06e98b77137846a5368efad50fbe22a788265186 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 12:10:32 -0500 Subject: [PATCH 01/13] Bumping version in apple news class --- includes/class-apple-news.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-apple-news.php b/includes/class-apple-news.php index 3d268ceb..b5961ffd 100644 --- a/includes/class-apple-news.php +++ b/includes/class-apple-news.php @@ -46,7 +46,7 @@ class Apple_News { * @var string * @access public */ - public static $version = '2.4.0'; + public static $version = '2.4.1'; /** * Link to support for the plugin on WordPress.org. From 4d9e9b8077ceae3801ffb51a8471545a24305b8d Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 12:10:45 -0500 Subject: [PATCH 02/13] Remove polyfills reference (not in use with testkit) --- tests/bootstrap.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9fa56868..74fa940e 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,8 +8,6 @@ /* phpcs:disable WordPressVIPMinimum.Files.IncludingFile.UsingVariable */ -const WP_TESTS_PHPUNIT_POLYFILLS_PATH = __DIR__ . '/../vendor/yoast/phpunit-polyfills'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound - const WP_TESTS_MULTISITE = 1; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound /** * Includes a PHP file if it exists. From 4161cff88fd1eefe0456f4fe854a2209728ef312 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 12:10:55 -0500 Subject: [PATCH 03/13] Ensure that the request class is loaded --- tests/apple-push-api/test-class-mime-builder.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/apple-push-api/test-class-mime-builder.php b/tests/apple-push-api/test-class-mime-builder.php index d8f9a2d4..87e10f46 100644 --- a/tests/apple-push-api/test-class-mime-builder.php +++ b/tests/apple-push-api/test-class-mime-builder.php @@ -16,6 +16,12 @@ */ class Apple_News_MIME_Builder_Test extends Apple_News_Testcase { + public function setUp(): void { + parent::setUp(); + + apple_news_require_file( dirname( __DIR__, 2 ) . '/includes/apple-push-api/request/class-request.php' ); + } + /** * Tests the behavior of adding JSON to the MIME builder. */ @@ -47,7 +53,9 @@ public function test_invalid_json() { $filename = 'article.json'; $json = ''; - $this->setExpectedException( 'Apple_Push_API\\Request\\Request_Exception', 'The attachment article.json could not be included in the request because it was empty.' ); + $this->expectException( \Apple_Push_API\Request\Request_Exception::class ); + $this->expectExceptionMessage( 'The attachment article.json could not be included in the request because it was empty.' ); + $builder->add_json_string( $name, $filename, $json ); } } From 03512e3f1a700dc17ffceb6a964f13a311ef1492 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 12:20:16 -0500 Subject: [PATCH 04/13] Use the WpOrg\Requests\Utility\CaseInsensitiveDictionary class if it exists In 6.4, WpOrg\Requests\Utility\CaseInsensitiveDictionary was introduced and using Requests_Utility_CaseInsensitiveDictionary will throw an exception --- tests/class-apple-news-testcase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/class-apple-news-testcase.php b/tests/class-apple-news-testcase.php index 59647dc3..867f5751 100644 --- a/tests/class-apple-news-testcase.php +++ b/tests/class-apple-news-testcase.php @@ -263,7 +263,9 @@ protected function add_http_response( 'body' => $body, 'cookies' => $cookies, 'filename' => $filename, - 'headers' => new Requests_Utility_CaseInsensitiveDictionary( $headers ), + 'headers' => class_exists( \WpOrg\Requests\Utility\CaseInsensitiveDictionary::class ) + ? new \WpOrg\Requests\Utility\CaseInsensitiveDictionary( $headers ) + : new Requests_Utility_CaseInsensitiveDictionary( $headers ), 'response' => $response, ] : null; } From 97dfabce474554c18c73b7cbf05a2b383e2a2116 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 13:45:25 -0500 Subject: [PATCH 05/13] Disable nonce checking when testing --- admin/class-admin-apple-meta-boxes.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/admin/class-admin-apple-meta-boxes.php b/admin/class-admin-apple-meta-boxes.php index 488d083a..90b321c6 100644 --- a/admin/class-admin-apple-meta-boxes.php +++ b/admin/class-admin-apple-meta-boxes.php @@ -95,8 +95,10 @@ public function do_publish( $post_id, $post ) { return; } - // Check the nonce. - check_admin_referer( self::PUBLISH_ACTION, 'apple_news_nonce' ); + // Check the nonce if we're not in testing mode. + if ( ! defined( 'MANTLE_IS_TESTING' ) || ! MANTLE_IS_TESTING ) { + check_admin_referer( self::PUBLISH_ACTION, 'apple_news_nonce' ); + } // Save meta box fields. self::save_post_meta( $post_id ); From b109c08cdc382305d49314bbd1509bbd81cc0d30 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 13:52:34 -0500 Subject: [PATCH 06/13] Testing CI From 90f6254dddd1e1488a77974268267fcecdbca6f2 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 13:55:35 -0500 Subject: [PATCH 07/13] Remove workflow_dispatch --- .github/workflows/phpunit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 5d719415..adf87eeb 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,7 +1,6 @@ name: Testing Suite on: - workflow_dispatch: pull_request: types: [ opened, synchronize, reopened, ready_for_review ] branches: From fe94f6a502a6d5b1e556eeb49db0a2271b94f8d6 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 13:55:58 -0500 Subject: [PATCH 08/13] More remove workflow_dispatch --- .github/workflows/node-tests.yml | 1 - .github/workflows/phpcs.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index 58b9a0c5..0e61cee7 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -1,7 +1,6 @@ name: Node Tests on: - workflow_dispatch: pull_request: types: [ opened, synchronize, reopened, ready_for_review ] branches: diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 29ffb3e5..f97e209c 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -1,7 +1,6 @@ name: PHP Coding Standards on: - workflow_dispatch: pull_request: types: [ opened, synchronize, reopened, ready_for_review ] branches: From 1e861cc94b4c98b62147c09b366b2eda4b1d0b0c Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 14:03:59 -0500 Subject: [PATCH 09/13] Adding more branches to CI --- .github/workflows/node-tests.yml | 1 + .github/workflows/phpcs.yml | 1 + .github/workflows/phpunit.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index 0e61cee7..b0d54fda 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -5,6 +5,7 @@ on: types: [ opened, synchronize, reopened, ready_for_review ] branches: - develop + - release/* jobs: node-tests: diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index f97e209c..6aff94f9 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -5,6 +5,7 @@ on: types: [ opened, synchronize, reopened, ready_for_review ] branches: - develop + - release/* jobs: phpcs: diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index adf87eeb..50abe80e 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -5,6 +5,7 @@ on: types: [ opened, synchronize, reopened, ready_for_review ] branches: - develop + - release/* jobs: php-tests: From ff7f1013d2ab0adaa8f15d4cb38bc41f78fd2541 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 14:42:01 -0500 Subject: [PATCH 10/13] Fix command --- .github/workflows/phpunit.yml | 2 +- tests/apple-push-api/test-class-mime-builder.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 50abe80e..4e7b4be0 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -17,6 +17,6 @@ jobs: if: github.event.pull_request.draft == false uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main with: - command: "test" + command: "phpunit" php: ${{ matrix.php }} wordpress: ${{ matrix.wordpress }} diff --git a/tests/apple-push-api/test-class-mime-builder.php b/tests/apple-push-api/test-class-mime-builder.php index 87e10f46..6cf537f1 100644 --- a/tests/apple-push-api/test-class-mime-builder.php +++ b/tests/apple-push-api/test-class-mime-builder.php @@ -16,6 +16,9 @@ */ class Apple_News_MIME_Builder_Test extends Apple_News_Testcase { + /** + * Sets up the test case. + */ public function setUp(): void { parent::setUp(); From 001530ac7040d221b647b284de143ce256e203f1 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 14:42:38 -0500 Subject: [PATCH 11/13] Enable multisite via the matrix --- .github/workflows/phpunit.yml | 1 + tests/bootstrap.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 4e7b4be0..b7a87ed5 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -18,5 +18,6 @@ jobs: uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main with: command: "phpunit" + multisite: ${{ matrix.multisite }} php: ${{ matrix.php }} wordpress: ${{ matrix.wordpress }} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 74fa940e..550bbbae 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,7 +8,6 @@ /* phpcs:disable WordPressVIPMinimum.Files.IncludingFile.UsingVariable */ -const WP_TESTS_MULTISITE = 1; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound /** * Includes a PHP file if it exists. * @@ -36,7 +35,7 @@ function apple_news_require_file( string $file ) { function () { // Disable VIP cache manager when testing against VIP Go integration. if ( method_exists( 'WPCOM_VIP_Cache_Manager', 'instance' ) ) { - remove_action( 'init', [ WPCOM_VIP_Cache_Manager::instance(), 'init' ] ); + remove_action( 'init', [ WPCOM_VIP_Cache_Manager::instance(), 'init' ] ); } // Set the permalink structure and domain options. From 7696a38cef82f892b97fc51a73067fbd30a26efd Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 14:45:07 -0500 Subject: [PATCH 12/13] Include push on branches too --- .github/workflows/node-tests.yml | 4 ++++ .github/workflows/phpcs.yml | 4 ++++ .github/workflows/phpunit.yml | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index b0d54fda..b06d6fb6 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -1,6 +1,10 @@ name: Node Tests on: + push: + branches: + - develop + - release/* pull_request: types: [ opened, synchronize, reopened, ready_for_review ] branches: diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 6aff94f9..1380f48f 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -1,6 +1,10 @@ name: PHP Coding Standards on: + push: + branches: + - develop + - release/* pull_request: types: [ opened, synchronize, reopened, ready_for_review ] branches: diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index b7a87ed5..3cd4ea6c 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,6 +1,10 @@ name: Testing Suite on: + push: + branches: + - develop + - release/* pull_request: types: [ opened, synchronize, reopened, ready_for_review ] branches: From ed6869f1bd8a1941feee34f757cc3445ed9584cb Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 15 Nov 2023 14:46:05 -0500 Subject: [PATCH 13/13] Fix matrix variable --- .github/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 3cd4ea6c..60f771d5 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -15,7 +15,7 @@ jobs: php-tests: strategy: matrix: - multisite: [0, 1] + multisite: [true, false] php: ['8.2', '8.1', '8.0'] wordpress: ["latest"] if: github.event.pull_request.draft == false