diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index 58b9a0c5..b06d6fb6 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -1,11 +1,15 @@ name: Node Tests on: - workflow_dispatch: + push: + branches: + - develop + - release/* pull_request: 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 29ffb3e5..1380f48f 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -1,11 +1,15 @@ name: PHP Coding Standards on: - workflow_dispatch: + push: + branches: + - develop + - release/* pull_request: 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 5d719415..60f771d5 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,22 +1,27 @@ name: Testing Suite on: - workflow_dispatch: + push: + branches: + - develop + - release/* pull_request: types: [ opened, synchronize, reopened, ready_for_review ] branches: - develop + - release/* 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 uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main with: - command: "test" + command: "phpunit" + multisite: ${{ matrix.multisite }} php: ${{ matrix.php }} wordpress: ${{ matrix.wordpress }} 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 ); 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. diff --git a/tests/apple-push-api/test-class-mime-builder.php b/tests/apple-push-api/test-class-mime-builder.php index d8f9a2d4..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,15 @@ */ class Apple_News_MIME_Builder_Test extends Apple_News_Testcase { + /** + * Sets up the test case. + */ + 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 +56,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 ); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9fa56868..550bbbae 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,9 +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. * @@ -38,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. 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; }