diff --git a/.gitattributes b/.gitattributes index a9f6429d08..84e5cd3bed 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,43 +1,4 @@ -*.stub linguist-language=PHP - -/.git export-ignore -/.github export-ignore -/.wordpress-org export-ignore -/.husky export-ignore -/node_modules export-ignore -/vendor export-ignore - -/bin export-ignore -/docs export-ignore -/tests export-ignore -/plugin-tests export-ignore -/plugins export-ignore -/plugins.json export-ignore - -/*.DS_store export-ignore -/.DS_store? export-ignore - -/.editorconfig export-ignore -/.eslintrc.js export-ignore -/.nvmrc export-ignore -/.wp-env.json export-ignore -/composer.json export-ignore -/composer.lock export-ignore -/package.json export-ignore -/package-lock.json export-ignore -phpcs.xml.dist export-ignore -/phpstan.neon.dist export-ignore -/phpunit.xml.dist export-ignore -/webpack.config.js export-ignore +# See . -/CONTRIBUTING.md export-ignore -/SECURITY.md export-ignore -/README.md export-ignore - -/.gitattributes export-ignore -/.gitignore export-ignore - -/modules/**/readme.txt export-ignore -/modules/**/.wordpress-org export-ignore - -/plugins/**/.wordpress-org export-ignore +# Improve highlighting for PHPStan stub files. +*.stub linguist-language=PHP diff --git a/.github/workflows/deploy-dotorg.yml b/.github/workflows/deploy-dotorg.yml deleted file mode 100644 index b6533a7afb..0000000000 --- a/.github/workflows/deploy-dotorg.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: Deploy to WordPress.org - -on: - release: - types: - - published - -jobs: - release: - name: Release Performance Lab Plugin - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: WordPress plugin deploy - uses: 10up/action-wordpress-plugin-deploy@stable - env: - SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} - SVN_USERNAME: ${{ secrets.SVN_USERNAME }} - SLUG: performance-lab - - - name: Upload release assets - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: ${{github.workspace}}/${{ github.event.repository.name }}.zip diff --git a/.github/workflows/deploy-standalone-plugins.yml b/.github/workflows/deploy-plugins.yml similarity index 100% rename from .github/workflows/deploy-standalone-plugins.yml rename to .github/workflows/deploy-plugins.yml diff --git a/.github/workflows/php-test-plugins.yml b/.github/workflows/php-test-plugins.yml index 4139c048bf..58edcece9d 100644 --- a/.github/workflows/php-test-plugins.yml +++ b/.github/workflows/php-test-plugins.yml @@ -67,7 +67,7 @@ jobs: run: npm run wp-env start - name: Composer Install run: npm run wp-env run tests-cli -- --env-cwd="wp-content/plugins/$(basename $(pwd))" composer install --no-interaction --no-progress - - name: Running single site unit tests for plugins - run: npm run test-php-plugins - - name: Running multisite unit tests for plugins - run: npm run test-php-multisite-plugins + - name: Running single site unit tests + run: npm run test-php + - name: Running multisite unit tests + run: npm run test-php-multisite diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml deleted file mode 100644 index c0f290b3af..0000000000 --- a/.github/workflows/php-test.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Unit Testing - -on: - push: - branches: - - trunk - - 'release/**' - # Only run if PHP-related files changed. - paths: - - '.github/workflows/php-test.yml' - - '**.php' - - '.wp-env.json' - - '**/package.json' - - 'package-lock.json' - - 'phpunit.xml.dist' - - 'tests/multisite.xml' - - 'composer.json' - - 'composer.lock' - pull_request: - # Only run if PHP-related files changed. - paths: - - '.github/workflows/php-test.yml' - - '**.php' - - '.wp-env.json' - - '**/package.json' - - 'package-lock.json' - - 'phpunit.xml.dist' - - 'tests/multisite.xml' - - 'composer.json' - - 'composer.lock' - types: - - opened - - reopened - - synchronize - workflow_dispatch: - -jobs: - php-test: - name: "PHP ${{ matrix.php }} / WP ${{ matrix.wp }}" - runs-on: ubuntu-latest - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - php: ['8.2', '8.1', '8.0', '7.4', '7.3', '7.2'] - wp: [ 'latest' ] - include: - - php: '7.4' - wp: '6.4' - - php: '8.3' - wp: 'trunk' - env: - WP_ENV_PHP_VERSION: ${{ matrix.php }} - WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} - steps: - - uses: styfle/cancel-workflow-action@0.12.1 - - uses: actions/checkout@v4 - - name: Setup Node.js (.nvmrc) - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: npm - - name: npm install - run: npm ci - - name: Remove standalone plugins from wp-env config - run: jq '.plugins = [.plugins[0]]' .wp-env.json > .wp-env.override.json - - name: Install WordPress - run: npm run wp-env start - - name: Composer Install - run: npm run wp-env run tests-cli -- --env-cwd="wp-content/plugins/$(basename $(pwd))" composer install --no-interaction --no-progress - - name: Running single site unit tests - run: npm run test-php - - name: Running multisite unit tests - run: npm run test-php-multisite diff --git a/.wp-env.json b/.wp-env.json index be6a31146e..2cedd753e1 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -1,11 +1,11 @@ { "core": null, "plugins": [ - ".", "./plugins/auto-sizes", "./plugins/dominant-color-images", "./plugins/embed-optimizer", "./plugins/optimization-detective", + "./plugins/performance-lab", "./plugins/speculation-rules", "./plugins/webp-uploads" ], @@ -13,6 +13,9 @@ "tests": { "config": { "FS_METHOD": "direct" + }, + "mappings": { + "/wp-content/plugins/performance": "." } } } diff --git a/bin/phpcs/phpcs.ruleset.xml b/bin/phpcs/phpcs.ruleset.xml index 02d5053b26..48c8261912 100644 --- a/bin/phpcs/phpcs.ruleset.xml +++ b/bin/phpcs/phpcs.ruleset.xml @@ -131,4 +131,8 @@ ./build/* + + + ./node_modules/* + ./vendor/* diff --git a/bin/plugin/commands/readme.js b/bin/plugin/commands/readme.js index b8ca0f354b..177e486d07 100644 --- a/bin/plugin/commands/readme.js +++ b/bin/plugin/commands/readme.js @@ -123,28 +123,25 @@ function getStableTag( readmeFilePath ) { async function updateReadme( settings ) { const pluginRoot = path.resolve( __dirname, '../../../' ); - const allPluginSlugs = [ - 'performance-lab', // TODO: Remove as of . - ...plugins, - ]; - if ( settings.plugin && ! allPluginSlugs.includes( settings.plugin ) ) { + if ( settings.plugin && ! plugins.includes( settings.plugin ) ) { throw new Error( `Unrecognized plugin: ${ settings.plugin }` ); } const pluginSlugs = []; + if ( settings.plugin ) { pluginSlugs.push( settings.plugin ); } else { - pluginSlugs.push( ...allPluginSlugs ); + pluginSlugs.push( ...plugins ); } for ( const pluginSlug of pluginSlugs ) { try { - const pluginDirectory = - 'performance-lab' === pluginSlug // TODO: Remove this condition as of . - ? pluginRoot - : path.resolve( pluginRoot, 'plugins', pluginSlug ); - + const pluginDirectory = path.resolve( + pluginRoot, + 'plugins', + pluginSlug + ); const readmeFilePath = path.resolve( pluginDirectory, 'readme.txt' @@ -157,6 +154,7 @@ async function updateReadme( settings ) { token: settings.token, } ); const status = updateReadmeChangelog( readmeFilePath, changelog ); + log( formats.success( `💃 ${ pluginSlug } successfully updated for version ${ stableTag }: ${ status }` diff --git a/bin/plugin/commands/since.js b/bin/plugin/commands/since.js index b00a87cef1..40ffe8f1ca 100644 --- a/bin/plugin/commands/since.js +++ b/bin/plugin/commands/since.js @@ -32,22 +32,15 @@ exports.options = [ exports.handler = async ( opt ) => { const isAllPlugins = ! opt.plugin; - if ( - ! isAllPlugins && - opt.plugin !== 'performance-lab' && // TODO: Remove this as of . - ! plugins.includes( opt.plugin ) - ) { + if ( ! isAllPlugins && ! plugins.includes( opt.plugin ) ) { throw new Error( `The plugin "${ opt.plugin }" is not a valid plugin managed as part of this project.` ); } + const pluginDirectories = []; const pluginRoot = path.resolve( __dirname, '../../../' ); - const pluginDirectories = []; - if ( isAllPlugins || opt.plugin === 'performance-lab' ) { - pluginDirectories.push( pluginRoot ); // TODO: Remove this as of . - } if ( isAllPlugins ) { for ( const pluginSlug of plugins ) { pluginDirectories.push( @@ -77,10 +70,6 @@ exports.handler = async ( opt ) => { } const version = readmeContentMatches[ 1 ]; - if ( pluginDirectory === pluginRoot ) { - ignore.push( '**/plugins' ); // TODO: Remove this as of . - } - patterns.push( `${ pluginDirectory }/**/*.php` ); patterns.push( `${ pluginDirectory }/**/*.js` ); diff --git a/bin/plugin/commands/versions.js b/bin/plugin/commands/versions.js index 001bb31752..08208d57d7 100644 --- a/bin/plugin/commands/versions.js +++ b/bin/plugin/commands/versions.js @@ -119,13 +119,8 @@ async function checkPluginDirectory( pluginDirectory ) { * @param {WPVersionsCommandOptions} opt Command options. */ exports.handler = async ( opt ) => { - const pluginRoot = path.resolve( __dirname, '../../../' ); - const pluginDirectories = []; - - if ( ! opt.plugin || 'performance-lab' === opt.plugin ) { - pluginDirectories.push( pluginRoot ); // TODO: Remove this after . - } + const pluginRoot = path.resolve( __dirname, '../../../' ); for ( const pluginSlug of plugins ) { if ( ! opt.plugin || pluginSlug === opt.plugin ) { diff --git a/composer.json b/composer.json index 4fb2198f61..032b1c96bc 100644 --- a/composer.json +++ b/composer.json @@ -71,6 +71,7 @@ "@lint:dominant-color-images", "@lint:embed-optimizer", "@lint:optimization-detective", + "@lint:performance-lab", "@lint:speculation-rules", "@lint:webp-uploads" ], @@ -78,46 +79,43 @@ "lint:dominant-color-images": "@lint -- ./plugins/dominant-color-images --standard=./plugins/dominant-color-images/phpcs.xml.dist", "lint:embed-optimizer": "@lint -- ./plugins/embed-optimizer --standard=./plugins/embed-optimizer/phpcs.xml.dist", "lint:optimization-detective": "@lint -- ./plugins/optimization-detective --standard=./plugins/optimization-detective/phpcs.xml.dist", + "lint:performance-lab": "@lint -- ./plugins/performance-lab --standard=./plugins/performance-lab/phpcs.xml.dist", "lint:speculation-rules": "@lint -- ./plugins/speculation-rules --standard=./plugins/speculation-rules/phpcs.xml.dist", "lint:webp-uploads": "@lint -- ./plugins/webp-uploads --standard=./plugins/webp-uploads/phpcs.xml.dist", "phpstan": "phpstan analyse --memory-limit=2048M", - "test": "phpunit --verbose --testsuite performance-lab", - "test-multisite": "phpunit -c tests/multisite.xml --verbose --testsuite performance-lab", - "test-multisite:all": [ - "@test-multisite", - "@test-multisite:plugins" - ], - "test-multisite:auto-sizes": "phpunit -c tests/multisite.xml --verbose --testsuite auto-sizes", - "test-multisite:dominant-color-images": "phpunit -c tests/multisite.xml --verbose --testsuite dominant-color-images", - "test-multisite:embed-optimizer": "phpunit -c tests/multisite.xml --verbose --testsuite embed-optimizer", - "test-multisite:optimization-detective": "phpunit -c tests/multisite.xml --verbose --testsuite optimization-detective", + "test": "phpunit", + "test-multisite": "@test -c tests/multisite.xml", "test-multisite:plugins": [ "@test-multisite:auto-sizes", "@test-multisite:dominant-color-images", "@test-multisite:embed-optimizer", "@test-multisite:optimization-detective", + "@test-multisite:performance-lab", "@test-multisite:speculation-rules", "@test-multisite:webp-uploads" ], - "test-multisite:speculation-rules": "phpunit -c tests/multisite.xml --verbose --testsuite speculation-rules", - "test-multisite:webp-uploads": "phpunit -c tests/multisite.xml --verbose --testsuite webp-uploads", - "test:all": [ - "@test", - "@test:plugins" - ], - "test:auto-sizes": "phpunit --verbose --testsuite auto-sizes", - "test:dominant-color-images": "phpunit --verbose --testsuite dominant-color-images", - "test:embed-optimizer": "phpunit --verbose --testsuite embed-optimizer", - "test:optimization-detective": "phpunit --verbose --testsuite optimization-detective", + "test-multisite:auto-sizes": "@test-multisite --verbose --testsuite auto-sizes", + "test-multisite:dominant-color-images": "@test-multisite --verbose --testsuite dominant-color-images", + "test-multisite:embed-optimizer": "@test-multisite --verbose --testsuite embed-optimizer", + "test-multisite:optimization-detective": "@test-multisite --verbose --testsuite optimization-detective", + "test-multisite:performance-lab": "@test-multisite --verbose --testsuite performance-lab", + "test-multisite:speculation-rules": "@test-multisite --verbose --testsuite speculation-rules", + "test-multisite:webp-uploads": "@test-multisite --verbose --testsuite webp-uploads", "test:plugins": [ "@test:auto-sizes", "@test:dominant-color-images", "@test:embed-optimizer", "@test:optimization-detective", + "@test:performance-lab", "@test:speculation-rules", "@test:webp-uploads" ], - "test:speculation-rules": "phpunit --verbose --testsuite speculation-rules", - "test:webp-uploads": "phpunit --verbose --testsuite webp-uploads" + "test:auto-sizes": "@test --verbose --testsuite auto-sizes", + "test:dominant-color-images": "@test --verbose --testsuite dominant-color-images", + "test:embed-optimizer": "@test --verbose --testsuite embed-optimizer", + "test:optimization-detective": "@test --verbose --testsuite optimization-detective", + "test:performance-lab": "@test --verbose --testsuite performance-lab", + "test:speculation-rules": "@test --verbose --testsuite speculation-rules", + "test:webp-uploads": "@test --verbose --testsuite webp-uploads" } } diff --git a/package.json b/package.json index 265a90ae40..78b0fdc02d 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ "readme": "./bin/plugin/cli.js readme", "versions": "./bin/plugin/cli.js versions", "build": "wp-scripts build", - "build-plugins": "npm-run-all 'build:plugin:!(performance-lab)'", - "build:plugin:performance-lab": "rm -rf build/performance-lab && mkdir -p build/performance-lab && git archive HEAD | tar -x -C build/performance-lab", + "build-plugins": "npm-run-all 'build:plugin:*'", + "build:plugin:performance-lab": "webpack --mode production --env plugin=performance-lab", "build:plugin:auto-sizes": "webpack --mode production --env plugin=auto-sizes", "build:plugin:dominant-color-images": "webpack --mode production --env plugin=dominant-color-images", "build:plugin:embed-optimizer": "webpack --mode production --env plugin=embed-optimizer", @@ -43,10 +43,8 @@ "format-php": "composer format", "phpstan": "composer phpstan", "lint-php": "composer lint:all", - "test-php": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test", - "test-php-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test-multisite", - "test-php-plugins": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test:plugins", - "test-php-multisite-plugins": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename $(pwd)) composer test-multisite:plugins", + "test-php": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test:plugins", + "test-php-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/performance composer test-multisite:plugins", "wp-env": "wp-env", "prepare": "husky install" }, diff --git a/performance.php b/performance.php new file mode 100644 index 0000000000..c11e86f95f --- /dev/null +++ b/performance.php @@ -0,0 +1,29 @@ +Performance Lab to install performance features instead. Otherwise, if wanting to contribute, please refer to the handbook page. + * Author: WordPress Performance Team + * Author URI: https://make.wordpress.org/performance/ + * Text Domain: performance-lab + * + * @package performance + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly. +} + +/** + * Notify the admin that the Performance monorepo is not a plugin, if they tried to install it as one. + */ +function perflab_monorepo_is_not_a_plugin(): void { + // Note: The following notice is not translated because it is never published to WordPress.org and so it will never get translations. + ?> +
+

The Performance monorepo is not a plugin rather a collection of performance features as plugins. Download Performance Lab to install performance features instead. Otherwise, if wanting to contribute, please refer to the handbook page.

+
+ - - WordPress Coding Standards for the Performance Lab Plugin + + WordPress Coding Standards for the Performance Features. - - includes/server-timing/object-cache.copy.php - - . - ./node_modules/* + + ./plugins/* - ./vendor/* diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9d05005a68..4b131a4e72 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,13 +4,13 @@ parameters: level: 8 treatPhpDocTypesAsCertain: false paths: - - load.php - - includes/ - - plugins/ - - tests/ + - plugins + - tests + - performance.php + - plugins/performance-lab/load.php bootstrapFiles: - - load.php - bin/phpstan/constants.php + - plugins/performance-lab/load.php - plugins/webp-uploads/load.php scanDirectories: - vendor/wp-phpunit/wp-phpunit/ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7f37f4faaa..3100189bf3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,15 @@ - ./tests - ./tests/utils - ./tests/plugins + ./tests/plugins/performance-lab ./tests/plugins/auto-sizes diff --git a/plugins.json b/plugins.json index de34862d23..b4abb9af58 100644 --- a/plugins.json +++ b/plugins.json @@ -4,6 +4,7 @@ "dominant-color-images", "embed-optimizer", "optimization-detective", + "performance-lab", "speculation-rules", "webp-uploads" ] diff --git a/.wordpress-org/banner-1544x500.png b/plugins/performance-lab/.wordpress-org/banner-1544x500.png similarity index 100% rename from .wordpress-org/banner-1544x500.png rename to plugins/performance-lab/.wordpress-org/banner-1544x500.png diff --git a/.wordpress-org/banner-772x250.png b/plugins/performance-lab/.wordpress-org/banner-772x250.png similarity index 100% rename from .wordpress-org/banner-772x250.png rename to plugins/performance-lab/.wordpress-org/banner-772x250.png diff --git a/.wordpress-org/blueprints/blueprint.json b/plugins/performance-lab/.wordpress-org/blueprints/blueprint.json similarity index 100% rename from .wordpress-org/blueprints/blueprint.json rename to plugins/performance-lab/.wordpress-org/blueprints/blueprint.json diff --git a/.wordpress-org/icon-128x128.png b/plugins/performance-lab/.wordpress-org/icon-128x128.png similarity index 100% rename from .wordpress-org/icon-128x128.png rename to plugins/performance-lab/.wordpress-org/icon-128x128.png diff --git a/.wordpress-org/icon-256x256.png b/plugins/performance-lab/.wordpress-org/icon-256x256.png similarity index 100% rename from .wordpress-org/icon-256x256.png rename to plugins/performance-lab/.wordpress-org/icon-256x256.png diff --git a/.wordpress-org/icon.svg b/plugins/performance-lab/.wordpress-org/icon.svg similarity index 100% rename from .wordpress-org/icon.svg rename to plugins/performance-lab/.wordpress-org/icon.svg diff --git a/includes/admin/load.php b/plugins/performance-lab/includes/admin/load.php similarity index 100% rename from includes/admin/load.php rename to plugins/performance-lab/includes/admin/load.php diff --git a/includes/admin/plugins.php b/plugins/performance-lab/includes/admin/plugins.php similarity index 100% rename from includes/admin/plugins.php rename to plugins/performance-lab/includes/admin/plugins.php diff --git a/includes/admin/server-timing.php b/plugins/performance-lab/includes/admin/server-timing.php similarity index 100% rename from includes/admin/server-timing.php rename to plugins/performance-lab/includes/admin/server-timing.php diff --git a/includes/server-timing/class-perflab-server-timing-metric.php b/plugins/performance-lab/includes/server-timing/class-perflab-server-timing-metric.php similarity index 100% rename from includes/server-timing/class-perflab-server-timing-metric.php rename to plugins/performance-lab/includes/server-timing/class-perflab-server-timing-metric.php diff --git a/includes/server-timing/class-perflab-server-timing.php b/plugins/performance-lab/includes/server-timing/class-perflab-server-timing.php similarity index 100% rename from includes/server-timing/class-perflab-server-timing.php rename to plugins/performance-lab/includes/server-timing/class-perflab-server-timing.php diff --git a/includes/server-timing/defaults.php b/plugins/performance-lab/includes/server-timing/defaults.php similarity index 100% rename from includes/server-timing/defaults.php rename to plugins/performance-lab/includes/server-timing/defaults.php diff --git a/includes/server-timing/hooks.php b/plugins/performance-lab/includes/server-timing/hooks.php similarity index 100% rename from includes/server-timing/hooks.php rename to plugins/performance-lab/includes/server-timing/hooks.php diff --git a/includes/server-timing/load.php b/plugins/performance-lab/includes/server-timing/load.php similarity index 100% rename from includes/server-timing/load.php rename to plugins/performance-lab/includes/server-timing/load.php diff --git a/includes/server-timing/object-cache.copy.php b/plugins/performance-lab/includes/server-timing/object-cache.copy.php similarity index 100% rename from includes/server-timing/object-cache.copy.php rename to plugins/performance-lab/includes/server-timing/object-cache.copy.php diff --git a/includes/site-health/audit-autoloaded-options/helper.php b/plugins/performance-lab/includes/site-health/audit-autoloaded-options/helper.php similarity index 100% rename from includes/site-health/audit-autoloaded-options/helper.php rename to plugins/performance-lab/includes/site-health/audit-autoloaded-options/helper.php diff --git a/includes/site-health/audit-autoloaded-options/hooks.php b/plugins/performance-lab/includes/site-health/audit-autoloaded-options/hooks.php similarity index 100% rename from includes/site-health/audit-autoloaded-options/hooks.php rename to plugins/performance-lab/includes/site-health/audit-autoloaded-options/hooks.php diff --git a/includes/site-health/audit-enqueued-assets/helper.php b/plugins/performance-lab/includes/site-health/audit-enqueued-assets/helper.php similarity index 100% rename from includes/site-health/audit-enqueued-assets/helper.php rename to plugins/performance-lab/includes/site-health/audit-enqueued-assets/helper.php diff --git a/includes/site-health/audit-enqueued-assets/hooks.php b/plugins/performance-lab/includes/site-health/audit-enqueued-assets/hooks.php similarity index 100% rename from includes/site-health/audit-enqueued-assets/hooks.php rename to plugins/performance-lab/includes/site-health/audit-enqueued-assets/hooks.php diff --git a/includes/site-health/avif-support/helper.php b/plugins/performance-lab/includes/site-health/avif-support/helper.php similarity index 100% rename from includes/site-health/avif-support/helper.php rename to plugins/performance-lab/includes/site-health/avif-support/helper.php diff --git a/includes/site-health/avif-support/hooks.php b/plugins/performance-lab/includes/site-health/avif-support/hooks.php similarity index 100% rename from includes/site-health/avif-support/hooks.php rename to plugins/performance-lab/includes/site-health/avif-support/hooks.php diff --git a/includes/site-health/load.php b/plugins/performance-lab/includes/site-health/load.php similarity index 100% rename from includes/site-health/load.php rename to plugins/performance-lab/includes/site-health/load.php diff --git a/includes/site-health/webp-support/helper.php b/plugins/performance-lab/includes/site-health/webp-support/helper.php similarity index 100% rename from includes/site-health/webp-support/helper.php rename to plugins/performance-lab/includes/site-health/webp-support/helper.php diff --git a/includes/site-health/webp-support/hooks.php b/plugins/performance-lab/includes/site-health/webp-support/hooks.php similarity index 100% rename from includes/site-health/webp-support/hooks.php rename to plugins/performance-lab/includes/site-health/webp-support/hooks.php diff --git a/load.php b/plugins/performance-lab/load.php similarity index 100% rename from load.php rename to plugins/performance-lab/load.php diff --git a/plugins/performance-lab/phpcs.xml.dist b/plugins/performance-lab/phpcs.xml.dist new file mode 100644 index 0000000000..28b28f160b --- /dev/null +++ b/plugins/performance-lab/phpcs.xml.dist @@ -0,0 +1,13 @@ + + + WordPress Coding Standards for the Performance Lab Plugin + + + + + + includes/server-timing/object-cache.copy.php + + + . + diff --git a/readme.txt b/plugins/performance-lab/readme.txt similarity index 100% rename from readme.txt rename to plugins/performance-lab/readme.txt diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 292ff50ded..65ae9358aa 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -40,48 +40,49 @@ if ( '--testsuite' === $arg && isset( $_SERVER['argv'][ $index + 1 ] ) && - 'performance-lab' !== $_SERVER['argv'][ $index + 1 ] && file_exists( TESTS_PLUGIN_DIR . '/plugins/' . $_SERVER['argv'][ $index + 1 ] ) ) { $plugin_name = $_SERVER['argv'][ $index + 1 ]; } } -if ( $plugin_name ) { - $plugin_test_path = TESTS_PLUGIN_DIR . '/plugins/' . $plugin_name; - tests_add_filter( - 'plugins_loaded', - static function () use ( $plugin_test_path, $plugin_name ): void { - // Check if plugin has a "plugin/plugin.php" file. - if ( file_exists( $plugin_test_path . '/' . $plugin_name . '.php' ) ) { - require_once $plugin_test_path . '/' . $plugin_name . '.php'; - } elseif ( file_exists( $plugin_test_path . '/load.php' ) ) { - // Check if plugin has a "plugin/load.php" file. - require_once $plugin_test_path . '/load.php'; - } else { - echo "Unable to locate standalone plugin bootstrap file in $plugin_test_path."; - exit( 1 ); - } - }, - 1 - ); -} else { - // Force plugin to be active. - $GLOBALS['wp_tests_options'] = array( - 'active_plugins' => array( basename( TESTS_PLUGIN_DIR ) . '/load.php' ), - ); +// Set default plugin to load if not specified. +if ( ! $plugin_name ) { + $plugin_name = 'performance-lab'; +} + +$plugin_test_path = TESTS_PLUGIN_DIR . '/plugins/' . $plugin_name; +tests_add_filter( + 'plugins_loaded', + static function () use ( $plugin_test_path, $plugin_name ): void { + // Check if plugin has a "plugin/plugin.php" file. + if ( file_exists( $plugin_test_path . '/' . $plugin_name . '.php' ) ) { + require_once $plugin_test_path . '/' . $plugin_name . '.php'; + } elseif ( file_exists( $plugin_test_path . '/load.php' ) ) { + // Check if plugin has a "plugin/load.php" file. + require_once $plugin_test_path . '/load.php'; + } else { + echo "Unable to locate standalone plugin bootstrap file in $plugin_test_path."; + exit( 1 ); + } + }, + 1 +); + +if ( 'performance-lab' === $plugin_name ) { // Add filter to ensure the plugin's admin integration is loaded for tests. tests_add_filter( 'plugins_loaded', - static function (): void { - require_once TESTS_PLUGIN_DIR . '/includes/admin/load.php'; - require_once TESTS_PLUGIN_DIR . '/includes/admin/server-timing.php'; - require_once TESTS_PLUGIN_DIR . '/includes/admin/plugins.php'; + static function () use ( $plugin_name ): void { + require_once TESTS_PLUGIN_DIR . '/plugins/' . $plugin_name . '/includes/admin/load.php'; + require_once TESTS_PLUGIN_DIR . '/plugins/' . $plugin_name . '/includes/admin/server-timing.php'; + require_once TESTS_PLUGIN_DIR . '/plugins/' . $plugin_name . '/includes/admin/plugins.php'; }, 1 ); } + // Start up the WP testing environment. require $_test_root . '/includes/bootstrap.php'; diff --git a/tests/testdata/modules/images/balloons.webp b/tests/data/images/balloons.webp similarity index 100% rename from tests/testdata/modules/images/balloons.webp rename to tests/data/images/balloons.webp diff --git a/tests/testdata/modules/images/car.jpeg b/tests/data/images/car.jpeg similarity index 100% rename from tests/testdata/modules/images/car.jpeg rename to tests/data/images/car.jpeg diff --git a/tests/testdata/modules/images/dice.png b/tests/data/images/dice.png similarity index 100% rename from tests/testdata/modules/images/dice.png rename to tests/data/images/dice.png diff --git a/tests/testdata/modules/images/earth.gif b/tests/data/images/earth.gif similarity index 100% rename from tests/testdata/modules/images/earth.gif rename to tests/data/images/earth.gif diff --git a/tests/testdata/modules/images/image.jpeg b/tests/data/images/image.jpeg similarity index 100% rename from tests/testdata/modules/images/image.jpeg rename to tests/data/images/image.jpeg diff --git a/tests/testdata/modules/images/image.jpg b/tests/data/images/image.jpg similarity index 100% rename from tests/testdata/modules/images/image.jpg rename to tests/data/images/image.jpg diff --git a/tests/testdata/modules/images/leaves.jpg b/tests/data/images/leaves.jpg similarity index 100% rename from tests/testdata/modules/images/leaves.jpg rename to tests/data/images/leaves.jpg diff --git a/tests/testdata/modules/images/paint.jpeg b/tests/data/images/paint.jpeg similarity index 100% rename from tests/testdata/modules/images/paint.jpeg rename to tests/data/images/paint.jpeg diff --git a/tests/plugins/auto-sizes/auto-sizes-test.php b/tests/plugins/auto-sizes/auto-sizes-test.php index f4c7e3b4fa..a80c9a7f94 100644 --- a/tests/plugins/auto-sizes/auto-sizes-test.php +++ b/tests/plugins/auto-sizes/auto-sizes-test.php @@ -19,7 +19,7 @@ class AutoSizesTests extends WP_UnitTestCase { * Setup shared fixtures. */ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ): void { - self::$image_id = $factory->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + self::$image_id = $factory->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); } /** diff --git a/tests/includes/admin/load-tests.php b/tests/plugins/performance-lab/includes/admin/load-tests.php similarity index 100% rename from tests/includes/admin/load-tests.php rename to tests/plugins/performance-lab/includes/admin/load-tests.php diff --git a/tests/includes/admin/server-timing-tests.php b/tests/plugins/performance-lab/includes/admin/server-timing-tests.php similarity index 100% rename from tests/includes/admin/server-timing-tests.php rename to tests/plugins/performance-lab/includes/admin/server-timing-tests.php diff --git a/tests/includes/server-timing/load-tests.php b/tests/plugins/performance-lab/includes/server-timing/load-tests.php similarity index 100% rename from tests/includes/server-timing/load-tests.php rename to tests/plugins/performance-lab/includes/server-timing/load-tests.php diff --git a/tests/includes/server-timing/perflab-server-timing-metric-tests.php b/tests/plugins/performance-lab/includes/server-timing/perflab-server-timing-metric-tests.php similarity index 100% rename from tests/includes/server-timing/perflab-server-timing-metric-tests.php rename to tests/plugins/performance-lab/includes/server-timing/perflab-server-timing-metric-tests.php diff --git a/tests/includes/server-timing/perflab-server-timing-tests.php b/tests/plugins/performance-lab/includes/server-timing/perflab-server-timing-tests.php similarity index 100% rename from tests/includes/server-timing/perflab-server-timing-tests.php rename to tests/plugins/performance-lab/includes/server-timing/perflab-server-timing-tests.php diff --git a/tests/includes/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php b/tests/plugins/performance-lab/includes/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php similarity index 100% rename from tests/includes/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php rename to tests/plugins/performance-lab/includes/site-health/audit-autoloaded-options/audit-autoloaded-options-test.php diff --git a/tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-helper-test.php b/tests/plugins/performance-lab/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-helper-test.php similarity index 100% rename from tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-helper-test.php rename to tests/plugins/performance-lab/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-helper-test.php diff --git a/tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-test.php b/tests/plugins/performance-lab/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-test.php similarity index 100% rename from tests/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-test.php rename to tests/plugins/performance-lab/includes/site-health/audit-enqueued-assets/audit-enqueued-assets-test.php diff --git a/tests/testdata/modules/site-health/audit-enqueued-assets/class-audit-assets-transients-set.php b/tests/plugins/performance-lab/includes/site-health/audit-enqueued-assets/class-audit-assets-transients-set.php similarity index 100% rename from tests/testdata/modules/site-health/audit-enqueued-assets/class-audit-assets-transients-set.php rename to tests/plugins/performance-lab/includes/site-health/audit-enqueued-assets/class-audit-assets-transients-set.php diff --git a/tests/testdata/modules/site-health/audit-enqueued-assets/class-site-health-mock-responses.php b/tests/plugins/performance-lab/includes/site-health/audit-enqueued-assets/class-site-health-mock-responses.php similarity index 100% rename from tests/testdata/modules/site-health/audit-enqueued-assets/class-site-health-mock-responses.php rename to tests/plugins/performance-lab/includes/site-health/audit-enqueued-assets/class-site-health-mock-responses.php diff --git a/tests/load-tests.php b/tests/plugins/performance-lab/load-tests.php similarity index 99% rename from tests/load-tests.php rename to tests/plugins/performance-lab/load-tests.php index 5c62d49660..4c497c79d2 100644 --- a/tests/load-tests.php +++ b/tests/plugins/performance-lab/load-tests.php @@ -171,7 +171,7 @@ private function set_up_mock_filesystem(): void { add_filter( 'filesystem_method_file', static function () { - return __DIR__ . '/utils/Filesystem/WP_Filesystem_MockFilesystem.php'; + return __DIR__ . '/../../utils/Filesystem/WP_Filesystem_MockFilesystem.php'; } ); add_filter( diff --git a/tests/plugins/webp-uploads/helper-tests.php b/tests/plugins/webp-uploads/helper-tests.php index cea0af9ed8..b1b5a1b837 100644 --- a/tests/plugins/webp-uploads/helper-tests.php +++ b/tests/plugins/webp-uploads/helper-tests.php @@ -35,7 +35,7 @@ public function data_provider_invalid_arguments_for_webp_uploads_generate_additi add_filter( 'wp_image_editors', '__return_empty_array' ); yield 'when no editor is present' => array( - self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ), + self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ), 'medium', array(), 'image/avif', @@ -43,21 +43,21 @@ public function data_provider_invalid_arguments_for_webp_uploads_generate_additi remove_filter( 'wp_image_editors', '__return_empty_array' ); yield 'when using a mime that is not supported' => array( - self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ), + self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ), 'medium', array(), 'image/avif', ); yield 'when no dimension is provided' => array( - self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ), + self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ), 'medium', array(), 'image/webp', ); yield 'when both dimensions are negative numbers' => array( - self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ), + self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ), 'medium', array( 'width' => -10, @@ -67,7 +67,7 @@ public function data_provider_invalid_arguments_for_webp_uploads_generate_additi ); yield 'when both dimensions are zero' => array( - self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ), + self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ), 'medium', array( 'width' => 0, @@ -90,7 +90,7 @@ public function it_should_create_an_image_with_the_default_suffix_in_the_same_lo // Create JPEG and WebP so that both versions are generated. $this->opt_in_to_jpeg_and_webp(); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); $size_data = array( 'width' => 300, 'height' => 300, @@ -119,7 +119,7 @@ public function it_should_create_a_file_in_the_specified_location_with_the_speci $this->markTestSkipped( 'Mime type image/webp is not supported.' ); } - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); $size_data = array( 'width' => 300, 'height' => 300, @@ -144,7 +144,7 @@ public function it_should_create_a_file_in_the_specified_location_with_the_speci */ public function it_should_prevent_processing_an_image_with_corrupted_metadata( callable $callback, string $size ): void { $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp' + TESTS_PLUGIN_DIR . '/tests/data/images/balloons.webp' ); $metadata = wp_get_attachment_metadata( $attachment_id ); wp_update_attachment_metadata( $attachment_id, $callback( $metadata ) ); @@ -192,7 +192,7 @@ public function it_should_prevent_to_create_an_image_size_when_attached_file_doe } $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $file = get_attached_file( $attachment_id ); $original_file = wp_get_original_image_path( $attachment_id ); @@ -216,7 +216,7 @@ public function it_should_prevent_to_create_an_image_size_when_attached_file_doe */ public function it_should_prevent_to_create_a_subsize_if_the_image_editor_does_not_exists(): void { $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); // Make sure no editor is available. @@ -233,7 +233,7 @@ public function it_should_prevent_to_create_a_subsize_if_the_image_editor_does_n */ public function it_should_prevent_to_upload_a_mime_that_is_not_supported_by_wordpress(): void { $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $result = webp_uploads_generate_image_size( $attachment_id, 'medium', 'image/vnd.zbrush.pcx' ); $this->assertWPError( $result ); @@ -248,7 +248,7 @@ public function it_should_prevent_to_upload_a_mime_that_is_not_supported_by_word public function it_should_prevent_to_process_an_image_when_the_editor_does_not_support_the_format(): void { // Make sure no editor is available. $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); add_filter( @@ -271,7 +271,7 @@ static function () { public function it_should_create_an_image_with_filter_webp_uploads_pre_generate_additional_image_source(): void { remove_all_filters( 'webp_uploads_pre_generate_additional_image_source' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); add_filter( 'webp_uploads_pre_generate_additional_image_source', @@ -305,7 +305,7 @@ static function () { public function it_should_use_filesize_when_filter_webp_uploads_pre_generate_additional_image_source_returns_filesize(): void { remove_all_filters( 'webp_uploads_pre_generate_additional_image_source' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); add_filter( 'webp_uploads_pre_generate_additional_image_source', @@ -340,7 +340,7 @@ static function () { public function it_should_return_an_error_when_filter_webp_uploads_pre_generate_additional_image_source_returns_wp_error(): void { remove_all_filters( 'webp_uploads_pre_generate_additional_image_source' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); add_filter( 'webp_uploads_pre_generate_additional_image_source', @@ -588,8 +588,8 @@ public function it_should_add_original_image_extension_to_the_webp_file_name_to_ public function data_provider_same_image_name(): array { return array( array( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/image.jpeg', - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/image.jpg', + TESTS_PLUGIN_DIR . '/tests/data/images/image.jpeg', + TESTS_PLUGIN_DIR . '/tests/data/images/image.jpg', ), ); } diff --git a/tests/plugins/webp-uploads/image-edit-tests.php b/tests/plugins/webp-uploads/image-edit-tests.php index 763806bda9..818a129424 100644 --- a/tests/plugins/webp-uploads/image-edit-tests.php +++ b/tests/plugins/webp-uploads/image-edit-tests.php @@ -22,7 +22,7 @@ public function set_up(): void { * @test */ public function it_should_backup_the_sources_structure_alongside_the_full_size(): void { - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); $this->assertEmpty( get_post_meta( $attachment_id, '_wp_attachment_backup_sizes', true ) ); @@ -72,7 +72,7 @@ public function it_should_restore_the_sources_array_from_the_backup_when_an_imag $this->markTestSkipped( 'Mime type image/webp is not supported.' ); } - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); $editor = new WP_Image_Edit( $attachment_id ); @@ -126,7 +126,7 @@ public function it_should_prevent_to_back_up_the_sources_when_the_sources_attrib // Disable the generation of the sources attributes. add_filter( 'webp_uploads_upload_image_mime_transforms', '__return_empty_array' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); $this->assertArrayNotHasKey( 'sources', $metadata ); @@ -159,7 +159,7 @@ public function it_should_prevent_to_backup_the_full_size_image_if_only_the_thum // Create JPEG and WebP. $this->opt_in_to_jpeg_and_webp(); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); $this->assertArrayHasKey( 'sources', $metadata ); @@ -211,7 +211,7 @@ public function it_should_backup_the_image_when_all_images_except_the_thumbnail_ $this->markTestSkipped( 'Editing image thumbnails separately is disabled' ); } - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); $editor = new WP_Image_Edit( $attachment_id ); @@ -266,7 +266,7 @@ static function () { ); $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $this->assertNotSame( wp_get_original_image_path( $attachment_id ), get_attached_file( $attachment_id ) ); @@ -314,7 +314,7 @@ public function it_should_validate_source_attribute_update_when_webp_edited(): v $this->markTestSkipped( 'Editing image thumbnails separately is disabled' ); } - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); $editor->crop( 1000, 200, 0, 0 )->save(); @@ -343,7 +343,7 @@ public function it_should_validate_source_attribute_update_when_webp_edited(): v * @test */ public function it_should_not_return_a_target_if_no_backup_image_exists(): void { - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $this->assertNull( webp_uploads_get_next_full_size_key_from_backup( $attachment_id ) ); } @@ -356,7 +356,7 @@ public function it_should_return_the_full_orig_target_key_when_only_one_edit_ima // Remove the filter to prevent the usage of the next target. remove_filter( 'wp_update_attachment_metadata', 'webp_uploads_update_attachment_metadata' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); $editor->rotate_right()->save(); @@ -370,7 +370,7 @@ public function it_should_return_the_full_orig_target_key_when_only_one_edit_ima * @test */ public function it_should_return_null_when_looking_for_a_target_that_is_already_used(): void { - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); $editor->rotate_right()->save(); @@ -387,7 +387,7 @@ public function it_should_use_the_next_available_hash_for_the_full_size_image_on // Create JPEG and WebP. $this->opt_in_to_jpeg_and_webp(); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); $editor->rotate_right()->save(); @@ -413,7 +413,7 @@ public function it_should_save_populate_the_backup_sources_with_the_next_target( // Remove the filter to prevent the usage of the next target. remove_filter( 'wp_update_attachment_metadata', 'webp_uploads_update_attachment_metadata' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); $editor->rotate_right()->save(); $this->assertTrue( $editor->success() ); @@ -438,7 +438,7 @@ public function it_should_store_the_metadata_on_the_next_available_hash(): void // Create JPEG and WebP. $this->opt_in_to_jpeg_and_webp(); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); $editor->rotate_right()->save(); @@ -475,7 +475,7 @@ public function it_should_prevent_to_store_an_empty_set_of_sources(): void { // Remove the filter to prevent the usage of the next target. remove_filter( 'wp_update_attachment_metadata', 'webp_uploads_update_attachment_metadata' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); $editor->rotate_right()->save(); @@ -495,7 +495,7 @@ public function it_should_store_the_next_image_hash_on_the_backup_sources(): voi $this->markTestSkipped( 'Mime type image/webp is not supported.' ); } - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); // Edit the image. $editor->rotate_right()->save(); @@ -522,7 +522,7 @@ public function it_should_create_backup_of_full_size_images_with_the_same_hash_k // Create JPEG and WebP. $this->opt_in_to_jpeg_and_webp(); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $editor = new WP_Image_Edit( $attachment_id ); $editor->rotate_right()->save(); diff --git a/tests/plugins/webp-uploads/load-tests.php b/tests/plugins/webp-uploads/load-tests.php index 9640f6b973..cdca4bf8d6 100644 --- a/tests/plugins/webp-uploads/load-tests.php +++ b/tests/plugins/webp-uploads/load-tests.php @@ -43,7 +43,7 @@ static function ( string $filename ) { * @test */ public function it_should_not_create_the_original_mime_type_for_jpeg_images(): void { - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); // There should be a WebP source, but no JPEG source for the full image. $this->assertImageHasSource( $attachment_id, 'image/webp' ); @@ -75,7 +75,7 @@ public function it_should_not_create_the_original_mime_type_for_jpeg_images(): v * @test */ public function it_should_create_the_original_mime_type_as_well_with_all_the_available_sources_for_the_specified_mime(): void { - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/balloons.webp' ); // There should be a WebP source, but no JPEG source for the full image. $this->assertImageNotHasSource( $attachment_id, 'image/jpeg' ); @@ -106,7 +106,7 @@ public function it_should_create_the_original_mime_type_as_well_with_all_the_ava public function it_should_create_jpeg_and_webp_for_jpeg_images_if_opted_in(): void { $this->opt_in_to_jpeg_and_webp(); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); // There should be JPEG and WebP sources for the full image. $this->assertImageHasSource( $attachment_id, 'image/jpeg' ); @@ -137,7 +137,7 @@ public function it_should_create_jpeg_and_webp_for_jpeg_images_if_opted_in(): vo public function it_should_create_jpeg_and_webp_for_jpeg_images_if_generate_webp_and_jpeg_set(): void { update_option( 'perflab_generate_webp_and_jpeg', true ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); // There should be JPEG and WebP sources for the full image. $this->assertImageHasSource( $attachment_id, 'image/jpeg' ); @@ -169,7 +169,7 @@ public function it_should_not_create_the_sources_property_if_no_transform_is_pro add_filter( 'webp_uploads_upload_image_mime_transforms', '__return_empty_array' ); $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); @@ -195,7 +195,7 @@ static function () { ); $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $this->assertImageHasSource( $attachment_id, 'image/jpeg' ); @@ -222,7 +222,7 @@ static function () { ); $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp' + TESTS_PLUGIN_DIR . '/tests/data/images/balloons.webp' ); $metadata = wp_get_attachment_metadata( $attachment_id ); @@ -241,7 +241,7 @@ static function () { */ public function it_should_create_a_webp_version_with_all_the_required_properties(): void { $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); @@ -271,7 +271,7 @@ public function it_should_create_the_full_size_images_when_no_size_is_available( add_filter( 'intermediate_image_sizes', '__return_empty_array' ); add_filter( 'fallback_intermediate_image_sizes', '__return_empty_array' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); $this->assertEmpty( $metadata['sizes'] ); @@ -298,7 +298,7 @@ static function () { ); $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); $this->assertStringEndsWith( '-scaled.jpg', get_attached_file( $attachment_id ) ); @@ -314,7 +314,7 @@ static function () { */ public function it_should_remove_the_generated_webp_images_when_the_attachment_is_deleted(): void { $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $file = get_attached_file( $attachment_id, true ); @@ -349,7 +349,7 @@ public function it_should_remove_the_generated_webp_images_when_the_attachment_i */ public function it_should_remove_the_attached_webp_version_if_the_attachment_is_force_deleted(): void { $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $file = get_attached_file( $attachment_id, true ); @@ -378,7 +378,7 @@ public function it_should_remove_full_size_images_when_no_size_image_exists(): v add_filter( 'intermediate_image_sizes', '__return_empty_array' ); add_filter( 'fallback_intermediate_image_sizes', '__return_empty_array' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $file = get_attached_file( $attachment_id, true ); $dirname = pathinfo( $file, PATHINFO_DIRNAME ); @@ -401,7 +401,7 @@ public function it_should_remove_full_size_images_when_no_size_image_exists(): v */ public function it_should_remove_the_backup_sizes_and_sources_if_the_attachment_is_deleted_after_edit(): void { $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $file = get_attached_file( $attachment_id, true ); @@ -471,7 +471,7 @@ public function it_should_prevent_replacing_a_webp_image(): void { $this->opt_in_to_jpeg_and_webp(); $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp' + TESTS_PLUGIN_DIR . '/tests/data/images/balloons.webp' ); $tag = wp_get_attachment_image( $attachment_id, 'medium', false, array( 'class' => "wp-image-{$attachment_id}" ) ); @@ -495,7 +495,7 @@ public function it_should_prevent_replacing_a_webp_image(): void { */ public function it_should_prevent_replacing_a_jpg_image_if_the_image_does_not_have_the_target_class_name(): void { $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); // Run critical hooks to satisfy webp_uploads_in_frontend_body() conditions. @@ -560,8 +560,8 @@ static function ( $mime_types ) { } public function provider_replace_images_with_different_extensions(): Generator { - yield 'An image with a .jpg extension' => array( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); - yield 'An image with a .jpeg extension' => array( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + yield 'An image with a .jpg extension' => array( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); + yield 'An image with a .jpeg extension' => array( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); } /** @@ -574,7 +574,7 @@ public function it_should_replace_all_the_images_including_the_full_size_image() $this->opt_in_to_jpeg_and_webp(); $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $tag = wp_get_attachment_image( $attachment_id, 'full', false, array( 'class' => "wp-image-{$attachment_id}" ) ); @@ -599,7 +599,7 @@ public function it_should_replace_all_the_images_including_the_full_size_image() public function it_should_prevent_replacing_an_image_with_no_available_sources(): void { add_filter( 'webp_uploads_upload_image_mime_transforms', '__return_empty_array' ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); $tag = wp_get_attachment_image( $attachment_id, 'full', false, array( 'class' => "wp-image-{$attachment_id}" ) ); $this->assertSame( $tag, webp_uploads_img_tag_update_mime_type( $tag, 'the_content', $attachment_id ) ); @@ -623,8 +623,8 @@ public function it_should_prevent_update_not_supported_images_with_no_available_ } public function data_provider_not_supported_webp_images(): Generator { - yield 'PNG image' => array( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dice.png' ); - yield 'GIFT image' => array( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/earth.gif' ); + yield 'PNG image' => array( TESTS_PLUGIN_DIR . '/tests/data/images/dice.png' ); + yield 'GIFT image' => array( TESTS_PLUGIN_DIR . '/tests/data/images/earth.gif' ); } /** @@ -641,7 +641,7 @@ static function () { } ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/paint.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/paint.jpeg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); foreach ( $metadata['sizes'] as $size ) { @@ -669,7 +669,7 @@ public function it_should_preserve_jpeg_subsizes_using_transform_filter(): void // Create JPEG and WebP. $this->opt_in_to_jpeg_and_webp(); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); $this->assertImageHasSource( $attachment_id, 'image/webp' ); $this->assertImageHasSource( $attachment_id, 'image/jpeg' ); @@ -698,7 +698,7 @@ static function () { $this->assertTrue( wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $metadata = wp_get_attachment_metadata( $attachment_id ); $this->assertArrayHasKey( 'sources', $metadata ); @@ -717,7 +717,7 @@ static function () { * @test */ public function it_should_replace_the_featured_image_to_webp_when_requesting_the_featured_image(): void { - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/paint.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/paint.jpeg' ); $post_id = self::factory()->post->create(); set_post_thumbnail( $post_id, $attachment_id ); @@ -742,7 +742,7 @@ static function () { } ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); $tag = wp_get_attachment_image( $attachment_id, 'medium', false, array( 'class' => "wp-image-{$attachment_id}" ) ); $this->assertNotSame( $tag, webp_uploads_img_tag_update_mime_type( $tag, 'the_content', $attachment_id ) ); @@ -760,7 +760,7 @@ public function it_should_create_webp_when_webp_is_smaller_than_jpegs(): void { add_filter( 'webp_uploads_discard_larger_generated_images', '__return_true' ); // Look for an image that contains all of the additional mime type images. - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); $tag = wp_get_attachment_image( $attachment_id, 'full', false, array( 'class' => "wp-image-{$attachment_id}" ) ); $expected_tag = $tag; $metadata = wp_get_attachment_metadata( $attachment_id ); @@ -800,7 +800,7 @@ public function it_should_create_webp_for_full_size_which_is_smaller_in_webp_for add_filter( 'wp_editor_set_quality', array( $this, 'force_webp_image_quality_86' ), PHP_INT_MAX, 2 ); // Look for an image that contains only full size mime type images. - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); $tag = wp_get_attachment_image( $attachment_id, 'full', false, array( 'class' => "wp-image-{$attachment_id}" ) ); $metadata = wp_get_attachment_metadata( $attachment_id ); $file = get_attached_file( $attachment_id, true ); @@ -827,7 +827,7 @@ public function it_should_create_webp_for_some_sizes_which_are_smaller_in_webp_f add_filter( 'wp_editor_set_quality', array( $this, 'force_webp_image_quality_86' ), PHP_INT_MAX, 2 ); // Look for an image that contains all of the additional mime type images. - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/balloons.webp' ); $tag = wp_get_attachment_image( $attachment_id, 'full', false, array( 'class' => "wp-image-{$attachment_id}" ) ); $expected_tag = $tag; $metadata = wp_get_attachment_metadata( $attachment_id ); @@ -859,7 +859,7 @@ public function it_should_add_fallback_script_if_content_has_updated_images(): v remove_all_actions( 'wp_footer' ); $attachment_id = self::factory()->attachment->create_upload_object( - TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' + TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); // Run critical hooks to satisfy webp_uploads_in_frontend_body() conditions. @@ -912,7 +912,7 @@ static function ( $sizes ) { add_image_size( 'allowed_size_400x300', 400, 300, true ); add_image_size( 'not_allowed_size_200x150', 200, 150, true ); - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); remove_image_size( 'allowed_size_400x300' ); remove_image_size( 'not_allowed_size_200x150' ); @@ -933,7 +933,7 @@ public function it_should_create_mime_types_for_allowed_sizes_only_via_global_va // TODO: This property should later be set via a new parameter on add_image_size(). $GLOBALS['_wp_additional_image_sizes']['allowed_size_400x300']['provide_additional_mime_types'] = true; - $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/car.jpeg' ); + $attachment_id = self::factory()->attachment->create_upload_object( TESTS_PLUGIN_DIR . '/tests/data/images/car.jpeg' ); remove_image_size( 'allowed_size_400x300' ); remove_image_size( 'not_allowed_size_200x150' ); @@ -951,7 +951,7 @@ public function it_should_set_quality_with_image_conversion(): void { // Temporary file path. $file = $this->temp_filename(); - $editor = wp_get_image_editor( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/dice.png', array( 'mime_type' => 'image/png' ) ); + $editor = wp_get_image_editor( TESTS_PLUGIN_DIR . '/tests/data/images/dice.png', array( 'mime_type' => 'image/png' ) ); // Quality setting for the source image. For PNG the fallback default of 82 is used. $this->assertSame( 82, $editor->get_quality(), 'Default quality setting for PNG is 82.' ); @@ -960,7 +960,7 @@ public function it_should_set_quality_with_image_conversion(): void { $editor->save( $file, 'image/webp' ); $this->assertSame( 82, $editor->get_quality(), 'Output image format is WebP. Quality setting for it should be 82 universally.' ); - $editor = wp_get_image_editor( TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg' ); + $editor = wp_get_image_editor( TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg' ); // Quality setting for the source image. For JPG the fallback default of 82 is used. $this->assertSame( 82, $editor->get_quality(), 'Default quality setting for JPG is 82.' ); diff --git a/tests/plugins/webp-uploads/rest-api-tests.php b/tests/plugins/webp-uploads/rest-api-tests.php index d509619368..5c49035247 100644 --- a/tests/plugins/webp-uploads/rest-api-tests.php +++ b/tests/plugins/webp-uploads/rest-api-tests.php @@ -29,7 +29,7 @@ static function ( $transforms ) { } ); - $file_location = TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg'; + $file_location = TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg'; $attachment_id = self::factory()->attachment->create_upload_object( $file_location ); $metadata = wp_get_attachment_metadata( $attachment_id ); @@ -76,7 +76,7 @@ static function ( $transforms ) { * @test */ public function it_should_check_media_details_in_rest_response(): void { - $file_location = TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/leaves.jpg'; + $file_location = TESTS_PLUGIN_DIR . '/tests/data/images/leaves.jpg'; $attachment_id = self::factory()->attachment->create_upload_object( $file_location ); $request = new WP_REST_Request(); diff --git a/tests/utils/TestCase/DominantColorTestCase.php b/tests/utils/TestCase/DominantColorTestCase.php index 592e867fba..36cbedb6f2 100644 --- a/tests/utils/TestCase/DominantColorTestCase.php +++ b/tests/utils/TestCase/DominantColorTestCase.php @@ -96,7 +96,7 @@ public function provider_get_dominant_color(): array { 'expected_transparency' => true, ), 'balloons_webp' => array( - 'image_path' => TESTS_PLUGIN_DIR . '/tests/testdata/modules/images/balloons.webp', + 'image_path' => TESTS_PLUGIN_DIR . '/tests/data/images/balloons.webp', 'expected_color' => array( 'c1bbb9', 'c0bbb9', 'c0bab8', 'c3bdbd', 'bfbab8' ), 'expected_transparency' => false, ),