diff --git a/.github/workflows/php-test-plugins.yml b/.github/workflows/php-test-plugins.yml index d34646fee5..7c07127a9c 100644 --- a/.github/workflows/php-test-plugins.yml +++ b/.github/workflows/php-test-plugins.yml @@ -90,7 +90,7 @@ jobs: npm run wp-env-test start fi - name: Composer Install - run: npm run wp-env-test run cli -- --env-cwd="wp-content/plugins/$(basename $(pwd))" composer install --no-interaction --no-progress + run: npm run wp-env-test run wordpress -- --env-cwd="wp-content/plugins/$(basename $(pwd))" composer install --no-interaction --no-progress - name: Update Composer Dependencies run: composer update --with-all-dependencies --no-interaction --no-progress - name: Install PHPUnit @@ -136,7 +136,7 @@ jobs: fi - name: Upload single site coverage reports to Codecov if: ${{ matrix.coverage == true }} - uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1 + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6.0.2 with: token: ${{ secrets.CODECOV_TOKEN }} directory: ./single-site-reports @@ -145,7 +145,7 @@ jobs: fail_ci_if_error: true - name: Upload multisite coverage reports to Codecov if: ${{ matrix.coverage == true }} - uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1 + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6.0.2 with: token: ${{ secrets.CODECOV_TOKEN }} directory: ./multisite-reports diff --git a/bin/test-php-watch.sh b/bin/test-php-watch.sh index 1dbfd13e2d..9933b9029e 100755 --- a/bin/test-php-watch.sh +++ b/bin/test-php-watch.sh @@ -29,5 +29,5 @@ while true; do echo "Running phpunit tests for $(tput bold)$plugin_slug$(tput sgr0):" # TODO: Interrupt when a change is made while running tests or re-run if change made since tests started running. # Note: This is calling phpunit directly and not the composer script due to extra noise it outputs. - npm run wp-env-test --silent -- run cli --env-cwd=/var/www/html/wp-content/plugins/performance -- vendor/bin/phpunit --testsuite "$plugin_slug" "$@" + npm run wp-env-test --silent -- run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance -- vendor/bin/phpunit --testsuite "$plugin_slug" "$@" done diff --git a/package.json b/package.json index 47fdcccefa..83c029f1ae 100644 --- a/package.json +++ b/package.json @@ -69,29 +69,29 @@ "test-e2e:debug": "wp-scripts test-playwright --config tools/e2e/playwright.config.ts --ui", "test-e2e:auto-sizes": "wp-scripts test-playwright --config tools/e2e/playwright.config.ts --project=auto-sizes", "lint-php": "composer lint:all", - "test-php": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:plugins", + "test-php": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:plugins", "test-php-watch": "./bin/test-php-watch.sh", - "test-php-multisite": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:plugins", - "test-php:performance-lab": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:performance-lab", - "test-php:auto-sizes": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:auto-sizes", - "test-php:dominant-color-images": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:dominant-color-images", - "test-php:embed-optimizer": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:embed-optimizer", - "test-php:image-prioritizer": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:image-prioritizer", - "test-php:optimization-detective": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:optimization-detective", - "test-php:speculation-rules": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:speculation-rules", - "test-php:view-transitions": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:view-transitions", - "test-php:web-worker-offloading": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:web-worker-offloading", - "test-php:webp-uploads": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:webp-uploads", - "test-php-multisite:performance-lab": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:performance-lab", - "test-php-multisite:auto-sizes": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:auto-sizes", - "test-php-multisite:dominant-color-images": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:dominant-color-images", - "test-php-multisite:embed-optimizer": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:embed-optimizer", - "test-php-multisite:image-prioritizer": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:image-prioritizer", - "test-php-multisite:optimization-detective": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:optimization-detective", - "test-php-multisite:speculation-rules": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:speculation-rules", - "test-php-multisite:view-transitions": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:view-transitions", - "test-php-multisite:web-worker-offloading": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:web-worker-offloading", - "test-php-multisite:webp-uploads": "wp-env --config=.wp-env.test.json run cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:webp-uploads", + "test-php-multisite": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:plugins", + "test-php:performance-lab": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:performance-lab", + "test-php:auto-sizes": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:auto-sizes", + "test-php:dominant-color-images": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:dominant-color-images", + "test-php:embed-optimizer": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:embed-optimizer", + "test-php:image-prioritizer": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:image-prioritizer", + "test-php:optimization-detective": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:optimization-detective", + "test-php:speculation-rules": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:speculation-rules", + "test-php:view-transitions": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:view-transitions", + "test-php:web-worker-offloading": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:web-worker-offloading", + "test-php:webp-uploads": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test:webp-uploads", + "test-php-multisite:performance-lab": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:performance-lab", + "test-php-multisite:auto-sizes": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:auto-sizes", + "test-php-multisite:dominant-color-images": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:dominant-color-images", + "test-php-multisite:embed-optimizer": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:embed-optimizer", + "test-php-multisite:image-prioritizer": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:image-prioritizer", + "test-php-multisite:optimization-detective": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:optimization-detective", + "test-php-multisite:speculation-rules": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:speculation-rules", + "test-php-multisite:view-transitions": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:view-transitions", + "test-php-multisite:web-worker-offloading": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:web-worker-offloading", + "test-php-multisite:webp-uploads": "wp-env --config=.wp-env.test.json run wordpress --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:webp-uploads", "update-test-case-snapshots": "bin/update-test-case-snapshots.sh", "wp-env": "wp-env", "wp-env-test": "wp-env --config=.wp-env.test.json", diff --git a/plugins/dominant-color-images/tests/data/class-testcase.php b/plugins/dominant-color-images/tests/data/class-testcase.php index f6026dde7c..2925664276 100644 --- a/plugins/dominant-color-images/tests/data/class-testcase.php +++ b/plugins/dominant-color-images/tests/data/class-testcase.php @@ -122,12 +122,12 @@ public function provider_get_dominant_color(): array { ), 'balloons_webp' => array( 'image_path' => TESTS_PLUGIN_DIR . '/tests/data/images/balloons.webp', - 'expected_color' => array( 'c1bbb9', 'c0bbb9', 'c0bab8', 'c3bdbd', 'bfbab8' ), + 'expected_color' => array( 'c1bbb9', 'c0bbb9', 'c0bab8', 'c3bdbd', 'bfbab8', 'c2bdbc' ), 'expected_transparency' => false, ), 'half_opaque' => array( 'image_path' => TESTS_PLUGIN_DIR . '/tests/data/images/half-opaque.png', - 'expected_color' => array( '7e7e7e' ), + 'expected_color' => array( '7e7e7e', 'ffffff' ), 'expected_transparency' => true, ), ); @@ -214,7 +214,7 @@ public function test_get_dominant_color_invalid( string $image_path ): void { $dominant_color_data = dominant_color_get_dominant_color_data( $attachment_id ); $this->assertWPError( $dominant_color_data ); - $this->assertStringContainsString( 'image_no_editor', $dominant_color_data->get_error_code() ); + $this->assertStringContainsString( 'unsupported_attachment_type', $dominant_color_data->get_error_code() ); } /** diff --git a/plugins/webp-uploads/tests/test-load.php b/plugins/webp-uploads/tests/test-load.php index d4c954411e..0a90d88023 100644 --- a/plugins/webp-uploads/tests/test-load.php +++ b/plugins/webp-uploads/tests/test-load.php @@ -774,10 +774,15 @@ public function test_it_should_replace_the_featured_image_to_webp_when_requestin * @return array> An array of valid image types. */ public function data_provider_supported_image_types(): array { - return array( + $data = array( 'webp' => array( 'webp' ), - 'avif' => array( 'avif' ), ); + + if ( $this->check_avif_encoding_support() ) { + $data['avif'] = array( 'avif' ); + } + + return $data; } /** @@ -786,12 +791,17 @@ public function data_provider_supported_image_types(): array { * @return array> An array of valid image types. */ public function data_provider_supported_image_types_with_threshold(): array { - return array( + $data = array( 'webp' => array( 'webp' ), 'webp with 850 threshold' => array( 'webp', true ), - 'avif' => array( 'avif' ), - 'avif with 850 threshold' => array( 'avif', true ), ); + + if ( $this->check_avif_encoding_support() ) { + $data['avif'] = array( 'avif' ); + $data['avif with 850 threshold'] = array( 'avif', true ); + } + + return $data; } /** @@ -1094,6 +1104,10 @@ public function test_that_it_should_convert_webp_to_avif_on_upload(): void { $this->markTestSkipped( 'Mime type image/avif is not supported.' ); } + if ( ! $this->check_avif_encoding_support() ) { + $this->markTestSkipped( 'AVIF encoding is not supported.' ); + } + $this->set_image_output_type( 'avif' ); $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/balloons.webp' ); @@ -1310,4 +1324,34 @@ public function test_webp_uploads_update_featured_image_picture_element_enabled( $featured_image = get_the_post_thumbnail( $post_id ); $this->assertStringStartsWith( 'newImage( 10, 10, 'white' ); + $i->setImageFormat( 'avif' ); + $i->getImageBlob(); + $encoding_support = true; + } catch ( ImagickException $e ) { + $encoding_support = false; + } + } else { + $encoding_support = false; + } + } + + return $encoding_support; + } }