diff --git a/.github/workflows/build-test-measure.yml b/.github/workflows/build-test-measure.yml index 05717da4a..abf610982 100644 --- a/.github/workflows/build-test-measure.yml +++ b/.github/workflows/build-test-measure.yml @@ -87,18 +87,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ steps.nvm.outputs.NVMRC }} - - - name: Get npm cache directory - id: npm-cache - run: echo "::set-output name=dir::$(npm config get cache)" - - - name: Configure npm cache - uses: actions/cache@v2 - with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- + cache: npm - name: Install Node dependencies run: npm ci @@ -295,6 +284,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ steps.nvm.outputs.NVMRC }} + cache: npm - name: Get Composer Cache Directory id: composer-cache @@ -311,18 +301,6 @@ jobs: - name: Install Composer dependencies run: composer install --prefer-dist --ignore-platform-reqs --no-progress --no-interaction - - name: Get npm cache directory - id: npm-cache - run: echo "::set-output name=dir::$(npm config get cache)" - - - name: Configure npm cache - uses: actions/cache@v2 - with: - path: ${{ steps.npm-cache.outputs.dir }} - key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - - name: Install Node dependencies run: npm ci env: @@ -339,9 +317,6 @@ jobs: - name: Install WP tests run: bash bin/ci/install-wp-tests.sh wordpress_test root '' 127.0.0.1:${{ job.services.mysql.ports['3306'] }} ${{ matrix.wp }} true - - name: Post install of WP tests - run: bash bin/ci/after-wp-install.sh ${{ matrix.wp }} /tmp/wordpress-tests - - name: Setup PCOV if: ${{ matrix.coverage == true }} # phpdocumentor/reflection has to be removed as it makes use of an outdated dependency, making pcov/clobber @@ -366,7 +341,7 @@ jobs: - name: Upload code coverage report if: ${{ matrix.coverage == true }} - uses: codecov/codecov-action@v1.5.2 + uses: codecov/codecov-action@v2.0.2 with: file: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/pwa/build/logs/clover.xml flags: php,unit diff --git a/bin/ci/after-wp-install.sh b/bin/ci/after-wp-install.sh deleted file mode 100755 index 92467c22d..000000000 --- a/bin/ci/after-wp-install.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -set -e - -WP_VERSION=$1 -WP_TESTS_DIR=$2 - -if [[ -z $WP_VERSION ]]; then - echo "usage: $0 " - exit 1 -fi - -if [[ $(php -r "echo PHP_VERSION;") == 8.0* ]]; then - echo "Installing compatible PHPUnit for use with PHP 8..." - - DIFF=$( - cat <<-EOF -diff --git a/composer.json b/composer.json -index 562c54a..0c6a247 100644 ---- a/composer.json -+++ b/composer.json -@@ -31,6 +31,20 @@ - } - } - }, -+ "autoload-dev": { -+ "files": [ -+ "${WP_TESTS_DIR}/includes/phpunit7/MockObject/Builder/NamespaceMatch.php", -+ "${WP_TESTS_DIR}/includes/phpunit7/MockObject/Builder/ParametersMatch.php", -+ "${WP_TESTS_DIR}/includes/phpunit7/MockObject/InvocationMocker.php", -+ "${WP_TESTS_DIR}/includes/phpunit7/MockObject/MockMethod.php" -+ ], -+ "exclude-from-classmap": [ -+ "vendor/phpunit/phpunit/src/Framework/MockObject/Builder/NamespaceMatch.php", -+ "vendor/phpunit/phpunit/src/Framework/MockObject/Builder/ParametersMatch.php", -+ "vendor/phpunit/phpunit/src/Framework/MockObject/InvocationMocker.php", -+ "vendor/phpunit/phpunit/src/Framework/MockObject/MockMethod.php" -+ ] -+ }, - "minimum-stability": "dev", - "prefer-stable": true, - "scripts": { - EOF - ) - - echo "${DIFF}" | git apply - - composer require --dev --ignore-platform-reqs --update-with-dependencies phpunit/phpunit:^7.5 - - PATH="$(composer config bin-dir --absolute):$PATH" - echo "done" -fi diff --git a/composer.json b/composer.json index 562c54a6f..7161c88a1 100644 --- a/composer.json +++ b/composer.json @@ -11,10 +11,10 @@ "automattic/vipwpcs": "^2.2", "civicrm/composer-downloads-plugin": "^3.0", "dealerdirect/phpcodesniffer-composer-installer": "0.7.1", - "phpcompatibility/phpcompatibility-wp": "2.1.1", "php-stubs/wordpress-stubs": "^5.3.2", - "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5", - "wp-coding-standards/wpcs": "2.3.0" + "phpcompatibility/phpcompatibility-wp": "2.1.1", + "wp-coding-standards/wpcs": "2.3.0", + "yoast/wp-test-utils": "^0.2.2" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index 04acbfc13..635e5a837 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,57 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c158d1680b3e630ead388b5f7a494b8b", + "content-hash": "df8e181c3517e1f4dc21583c6699d2c8", "packages": [], "packages-dev": [ + { + "name": "antecedent/patchwork", + "version": "2.1.15", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "0430ceaac7f447f1778c199ec19d7e4362a6f961" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/0430ceaac7f447f1778c199ec19d7e4362a6f961", + "reference": "0430ceaac7f447f1778c199ec19d7e4362a6f961", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "http://patchwork2.org/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "support": { + "issues": "https://github.com/antecedent/patchwork/issues", + "source": "https://github.com/antecedent/patchwork/tree/2.1.15" + }, + "time": "2021-08-22T08:00:13+00:00" + }, { "name": "automattic/vipwpcs", "version": "2.3.2", @@ -59,6 +107,76 @@ }, "time": "2021-04-28T16:41:50+00:00" }, + { + "name": "brain/monkey", + "version": "2.6.0", + "source": { + "type": "git", + "url": "https://github.com/Brain-WP/BrainMonkey.git", + "reference": "7042140000b4b18034c0c0010d86274a00f25442" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/7042140000b4b18034c0c0010d86274a00f25442", + "reference": "7042140000b4b18034c0c0010d86274a00f25442", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.0", + "mockery/mockery": ">=0.9 <2", + "php": ">=5.6.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || ^0.7", + "phpcompatibility/php-compatibility": "^9.3.0", + "phpunit/phpunit": "^5.7.9 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-version/1": "1.x-dev", + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Brain\\Monkey\\": "src/" + }, + "files": [ + "inc/api.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Giuseppe Mazzapica", + "email": "giuseppe.mazzapica@gmail.com", + "homepage": "https://gmazzap.me", + "role": "Developer" + } + ], + "description": "Mocking utility for PHP functions and WordPress plugin API", + "keywords": [ + "Monkey Patching", + "interception", + "mock", + "mock functions", + "mockery", + "patchwork", + "redefinition", + "runkit", + "test", + "testing" + ], + "support": { + "issues": "https://github.com/Brain-WP/BrainMonkey/issues", + "source": "https://github.com/Brain-WP/BrainMonkey" + }, + "time": "2020-10-13T17:56:14+00:00" + }, { "name": "civicrm/composer-downloads-plugin", "version": "v3.0.1", @@ -241,6 +359,126 @@ }, "time": "2015-06-14T21:17:01+00:00" }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "time": "2020-07-09T08:09:16+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "31467aeb3ca3188158613322d66df81cedd86626" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/31467aeb3ca3188158613322d66df81cedd86626", + "reference": "31467aeb3ca3188158613322d66df81cedd86626", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.10|^6.5|^7.5|^8.5|^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "support": { + "issues": "https://github.com/mockery/mockery/issues", + "source": "https://github.com/mockery/mockery/tree/1.3.4" + }, + "time": "2021-02-24T09:51:00+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.7.0", @@ -2112,6 +2350,135 @@ "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, "time": "2020-05-13T23:57:56+00:00" + }, + { + "name": "yoast/phpunit-polyfills", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", + "reference": "f014fb21c2b0038fd329515d59025af42fb98715" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/f014fb21c2b0038fd329515d59025af42fb98715", + "reference": "f014fb21c2b0038fd329515d59025af42fb98715", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^0.5", + "php-parallel-lint/php-parallel-lint": "^1.3.0", + "yoast/yoastcs": "^2.1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "files": [ + "phpunitpolyfills-autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Team Yoast", + "email": "support@yoast.com", + "homepage": "https://yoast.com" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Yoast/PHPUnit-Polyfills/graphs/contributors" + } + ], + "description": "Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests", + "homepage": "https://github.com/Yoast/PHPUnit-Polyfills", + "keywords": [ + "phpunit", + "polyfill", + "testing" + ], + "support": { + "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues", + "source": "https://github.com/Yoast/PHPUnit-Polyfills" + }, + "time": "2021-08-09T16:28:08+00:00" + }, + { + "name": "yoast/wp-test-utils", + "version": "0.2.2", + "source": { + "type": "git", + "url": "https://github.com/Yoast/wp-test-utils.git", + "reference": "896f7640d86162ff7a0dc6ce59f8837f284521c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Yoast/wp-test-utils/zipball/896f7640d86162ff7a0dc6ce59f8837f284521c5", + "reference": "896f7640d86162ff7a0dc6ce59f8837f284521c5", + "shasum": "" + }, + "require": { + "brain/monkey": "^2.6.0", + "php": ">=5.6", + "yoast/phpunit-polyfills": "^1.0.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^0.5", + "php-parallel-lint/php-parallel-lint": "^1.3.0", + "yoast/yoastcs": "^2.1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Team Yoast", + "email": "support@yoast.com", + "homepage": "https://yoast.com" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Yoast/wp-test-utils/graphs/contributors" + } + ], + "description": "PHPUnit cross-version compatibility layer for testing plugins and themes build for WordPress", + "homepage": "https://github.com/Yoast/wp-test-utils/", + "keywords": [ + "brainmonkey", + "integration-testing", + "phpunit", + "unit-testing", + "wordpress" + ], + "support": { + "issues": "https://github.com/Yoast/wp-test-utils/issues", + "source": "https://github.com/Yoast/wp-test-utils" + }, + "time": "2021-06-21T03:45:02+00:00" } ], "aliases": [], diff --git a/tests/components/test-class-wp-service-worker-caching-routes.php b/tests/components/test-class-wp-service-worker-caching-routes.php index 9945d83f8..ebaad84e3 100644 --- a/tests/components/test-class-wp-service-worker-caching-routes.php +++ b/tests/components/test-class-wp-service-worker-caching-routes.php @@ -5,12 +5,14 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Worker_Caching_Routes. * * @coversDefaultClass WP_Service_Worker_Caching_Routes */ -class Test_WP_Service_Worker_Caching_Routes extends WP_UnitTestCase { +class Test_WP_Service_Worker_Caching_Routes extends TestCase { /** * Tested instance. @@ -280,14 +282,14 @@ public function test_prepare_strategy_args_for_js_export() { ) ); - $this->assertContains( WP_Service_Worker_Caching_Routes::STRATEGY_NETWORK_FIRST, $prepared ); - $this->assertContains( '"strategy":"NetworkFirst"', $prepared ); - $this->assertContains( '"networkTimeoutSeconds":2', $prepared ); - $this->assertContains( '"cacheName":"bank-cash"', $prepared ); - $this->assertContains( '{"maxEntries":4,"maxAgeSeconds":20}', $prepared ); - $this->assertContains( 'broadcastUpdate', $prepared ); - $this->assertContains( 'BroadcastUpdatePlugin', $prepared ); - $this->assertContains( 'expiration', $prepared ); - $this->assertContains( 'ExpirationPlugin', $prepared ); + $this->assertStringContainsString( WP_Service_Worker_Caching_Routes::STRATEGY_NETWORK_FIRST, $prepared ); + $this->assertStringContainsString( '"strategy":"NetworkFirst"', $prepared ); + $this->assertStringContainsString( '"networkTimeoutSeconds":2', $prepared ); + $this->assertStringContainsString( '"cacheName":"bank-cash"', $prepared ); + $this->assertStringContainsString( '{"maxEntries":4,"maxAgeSeconds":20}', $prepared ); + $this->assertStringContainsString( 'broadcastUpdate', $prepared ); + $this->assertStringContainsString( 'BroadcastUpdatePlugin', $prepared ); + $this->assertStringContainsString( 'expiration', $prepared ); + $this->assertStringContainsString( 'ExpirationPlugin', $prepared ); } } diff --git a/tests/components/test-class-wp-service-worker-core-asset-caching-component.php b/tests/components/test-class-wp-service-worker-core-asset-caching-component.php index f11d5a345..daefc542d 100644 --- a/tests/components/test-class-wp-service-worker-core-asset-caching-component.php +++ b/tests/components/test-class-wp-service-worker-core-asset-caching-component.php @@ -5,12 +5,14 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Worker_Core_Asset_Caching_Component. * * @coversDefaultClass WP_Service_Worker_Core_Asset_Caching_Component */ -class Test_WP_Service_Worker_Core_Asset_Caching_Component extends WP_UnitTestCase { +class Test_WP_Service_Worker_Core_Asset_Caching_Component extends TestCase { /** * Get data for test_serve. diff --git a/tests/components/test-class-wp-service-worker-navigation-routing-component.php b/tests/components/test-class-wp-service-worker-navigation-routing-component.php index c3fb7626c..db2f20eb4 100644 --- a/tests/components/test-class-wp-service-worker-navigation-routing-component.php +++ b/tests/components/test-class-wp-service-worker-navigation-routing-component.php @@ -5,12 +5,14 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Worker_Navigation_Routing_Component. * * @coversDefaultClass WP_Service_Worker_Navigation_Routing_Component */ -class Test_WP_Service_Worker_Navigation_Routing_Component extends WP_UnitTestCase { +class Test_WP_Service_Worker_Navigation_Routing_Component extends TestCase { /** * Test registering a route. diff --git a/tests/components/test-class-wp-service-worker-plugin-asset-caching-component.php b/tests/components/test-class-wp-service-worker-plugin-asset-caching-component.php index db73abff9..ded66c491 100644 --- a/tests/components/test-class-wp-service-worker-plugin-asset-caching-component.php +++ b/tests/components/test-class-wp-service-worker-plugin-asset-caching-component.php @@ -5,12 +5,14 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Worker_Plugin_Asset_Caching_Component. * * @coversDefaultClass WP_Service_Worker_Plugin_Asset_Caching_Component */ -class Test_WP_Service_Worker_Plugin_Asset_Caching_Component extends WP_UnitTestCase { +class Test_WP_Service_Worker_Plugin_Asset_Caching_Component extends TestCase { /** * Get data for test_serve. diff --git a/tests/components/test-class-wp-service-worker-precaching-routes.php b/tests/components/test-class-wp-service-worker-precaching-routes.php index a0ea57c25..377547073 100644 --- a/tests/components/test-class-wp-service-worker-precaching-routes.php +++ b/tests/components/test-class-wp-service-worker-precaching-routes.php @@ -5,12 +5,14 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Worker_Precaching_Routes. * * @coversDefaultClass WP_Service_Worker_Precaching_Routes */ -class Test_WP_Service_Worker_Precaching_Routes extends WP_UnitTestCase { +class Test_WP_Service_Worker_Precaching_Routes extends TestCase { /** * Tested instance. diff --git a/tests/components/test-class-wp-service-worker-theme-asset-caching-component.php b/tests/components/test-class-wp-service-worker-theme-asset-caching-component.php index e22595ed8..66f1a3729 100644 --- a/tests/components/test-class-wp-service-worker-theme-asset-caching-component.php +++ b/tests/components/test-class-wp-service-worker-theme-asset-caching-component.php @@ -5,12 +5,14 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Worker_Theme_Asset_Caching_Component. * * @coversDefaultClass WP_Service_Worker_Theme_Asset_Caching_Component */ -class Test_WP_Service_Worker_Theme_Asset_Caching_Component extends WP_UnitTestCase { +class Test_WP_Service_Worker_Theme_Asset_Caching_Component extends TestCase { /** * Get data for test_serve. diff --git a/tests/components/test-class-wp-service-worker-uploaded-image-caching-component.php b/tests/components/test-class-wp-service-worker-uploaded-image-caching-component.php index e936f0668..204fec5c6 100644 --- a/tests/components/test-class-wp-service-worker-uploaded-image-caching-component.php +++ b/tests/components/test-class-wp-service-worker-uploaded-image-caching-component.php @@ -5,12 +5,14 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Worker_Uploaded_Image_Caching_Component. * * @coversDefaultClass WP_Service_Worker_Uploaded_Image_Caching_Component */ -class Test_WP_Service_Worker_Uploaded_Image_Caching_Component extends WP_UnitTestCase { +class Test_WP_Service_Worker_Uploaded_Image_Caching_Component extends TestCase { /** * Get data for test_serve. diff --git a/tests/test-class-wp-service-worker-scripts.php b/tests/test-class-wp-service-worker-scripts.php index 7c51c7bbc..b22a66ecf 100644 --- a/tests/test-class-wp-service-worker-scripts.php +++ b/tests/test-class-wp-service-worker-scripts.php @@ -5,10 +5,12 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Worker_Scripts. */ -class Test_WP_Service_Worker_Scripts extends WP_UnitTestCase { +class Test_WP_Service_Worker_Scripts extends TestCase { /** * Tested instance. diff --git a/tests/test-class-wp-service-workers.php b/tests/test-class-wp-service-workers.php index b8d174843..465eb5a69 100644 --- a/tests/test-class-wp-service-workers.php +++ b/tests/test-class-wp-service-workers.php @@ -5,10 +5,12 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Service_Workers. */ -class Test_WP_Service_Workers extends WP_UnitTestCase { +class Test_WP_Service_Workers extends TestCase { /** * Tested instance. @@ -69,9 +71,9 @@ public function test_serve_request_front() { $output = ob_get_clean(); $this->assertSame( 0, get_current_user_id() ); - $this->assertContains( $this->return_foo_sw(), $output ); - $this->assertContains( $this->return_bar_sw(), $output ); - $this->assertNotContains( $this->return_baz_sw(), $output ); + $this->assertStringContainsString( $this->return_foo_sw(), $output ); + $this->assertStringContainsString( $this->return_bar_sw(), $output ); + $this->assertStringNotContainsString( $this->return_baz_sw(), $output ); $this->assertTrue( strpos( $output, $this->return_foo_sw() ) < strpos( $output, $this->return_bar_sw() ) ); @@ -96,9 +98,9 @@ public function test_serve_request_admin() { $output = ob_get_clean(); $this->assertSame( 0, get_current_user_id() ); - $this->assertContains( $this->return_foo_sw(), $output ); - $this->assertNotContains( $this->return_bar_sw(), $output ); - $this->assertContains( $this->return_baz_sw(), $output ); + $this->assertStringContainsString( $this->return_foo_sw(), $output ); + $this->assertStringNotContainsString( $this->return_bar_sw(), $output ); + $this->assertStringContainsString( $this->return_baz_sw(), $output ); $this->assertTrue( strpos( $output, $this->return_foo_sw() ) < strpos( $output, $this->return_baz_sw() ) ); @@ -124,7 +126,7 @@ public function test_serve_request_bad_src_callback() { wp_service_workers()->serve_request(); $output = ob_get_clean(); - $this->assertContains( 'Service worker src is invalid', $output ); + $this->assertStringContainsString( 'Service worker src is invalid', $output ); } /** @@ -146,7 +148,7 @@ public function test_serve_request_bad_src_url() { wp_service_workers()->serve_request(); $output = ob_get_clean(); - $this->assertContains( 'Service worker src is invalid', $output ); + $this->assertStringContainsString( 'Service worker src is invalid', $output ); } /** diff --git a/tests/test-class-wp-web-app-manifest.php b/tests/test-class-wp-web-app-manifest.php index cdfadcc1a..6fd072f26 100644 --- a/tests/test-class-wp-web-app-manifest.php +++ b/tests/test-class-wp-web-app-manifest.php @@ -5,10 +5,12 @@ * @package PWA */ +use Yoast\WPTestUtils\WPIntegration\TestCase; + /** * Tests for class WP_Web_App_Manifest. */ -class Test_WP_Web_App_Manifest extends WP_UnitTestCase { +class Test_WP_Web_App_Manifest extends TestCase { /** * Tested instance. @@ -112,7 +114,7 @@ public function test_manifest_link_and_meta() { add_filter( 'apple_touch_startup_images', function ( $images ) use ( $added_images ) { - $this->assertInternalType( 'array', $images ); + $this->assertIsArray( $images ); $this->assertCount( 1, $images ); $images = array_merge( $images, $added_images ); $images[] = array( 'bad' => 'yes' ); @@ -125,20 +127,20 @@ function ( $images ) use ( $added_images ) { $output = ob_get_clean(); $this->assertSame( 3, substr_count( $output, 'assertContains( sprintf( '', esc_url( get_site_icon_url() ) ), $output ); + $this->assertStringContainsString( sprintf( '', esc_url( get_site_icon_url() ) ), $output ); foreach ( $added_images as $added_image ) { $tag = sprintf( 'assertContains( $tag, $output ); + $this->assertStringContainsString( $tag, $output ); } - $this->assertContains( 'assertContains( rest_url( WP_Web_App_Manifest::REST_NAMESPACE . WP_Web_App_Manifest::REST_ROUTE ), $output ); - $this->assertContains( 'assertStringContainsString( rest_url( WP_Web_App_Manifest::REST_NAMESPACE . WP_Web_App_Manifest::REST_ROUTE ), $output ); + $this->assertStringContainsString( '