From c62045a3f4c2b4f0f143e56f580a8bb1f2eddced Mon Sep 17 00:00:00 2001 From: Michael Dinerstein Date: Thu, 11 Apr 2024 08:00:02 -0700 Subject: [PATCH 1/6] update: PHP and XDebug version, add wp-config.php values --- composer.json | 5 +++-- docker/Dockerfile | 6 +++--- local/config/wp-config.php | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 0370c6a..387ccf1 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ] }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { "composer/installers": "^1.9", @@ -30,10 +30,11 @@ "wp-phpunit/wp-phpunit": "^6.3", "yoast/phpunit-polyfills": "^2.0", "phpunit/phpunit": "^9.6", + "codeception/codeception": "^5.1", "codeception/module-asserts": "*", "codeception/util-universalframework": "*", "codeception/module-rest": "*", - "lucatume/wp-browser": "^3.1", + "lucatume/wp-browser": "^4.1", "php-coveralls/php-coveralls": "2.4.3" }, "scripts": { diff --git a/docker/Dockerfile b/docker/Dockerfile index 286de44..0daabca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,9 @@ -ARG PHP_VERSION=7.4 +ARG PHP_VERSION=8.1 FROM wordpress:php${PHP_VERSION}-apache -ARG XDEBUG_VERSION=2.9.6 +# See: https://xdebug.org/docs/compat to match the Xdebug version with the PHP version. +ARG XDEBUG_VERSION=3.3.1 RUN apt-get update; \ apt-get install -y --no-install-recommends \ @@ -13,7 +14,6 @@ RUN apt-get update; \ COPY php.ini /usr/local/etc/php/php.ini -# Setup xdebug. The latest version supported by PHP 5.6 is 2.5.5. RUN pecl install "xdebug-${XDEBUG_VERSION}"; \ docker-php-ext-enable xdebug diff --git a/local/config/wp-config.php b/local/config/wp-config.php index b780944..50f1767 100644 --- a/local/config/wp-config.php +++ b/local/config/wp-config.php @@ -12,6 +12,17 @@ define( 'DB_CHARSET', 'utf8' ); define( 'DB_COLLATE', '' ); +$table_prefix = 'wptests_'; + +define( 'AUTH_KEY', 'value' ); +define( 'SECURE_AUTH_KEY', 'value' ); +define( 'LOGGED_IN_KEY', 'value' ); +define( 'NONCE_KEY', 'value' ); +define( 'AUTH_SALT', 'value' ); +define( 'SECURE_AUTH_SALT', 'value' ); +define( 'LOGGED_IN_SALT', 'value' ); +define( 'NONCE_SALT', 'value' ); + define( 'ABSPATH', __DIR__ . '/' ); require_once ABSPATH . 'wp-settings.php'; \ No newline at end of file From 5275b58fd1777b2da5489800f5120ddfd374622d Mon Sep 17 00:00:00 2001 From: Michael Dinerstein Date: Thu, 11 Apr 2024 08:04:53 -0700 Subject: [PATCH 2/6] fix: enable XDEBUG_MODE=coverage in Dockerfile --- docker/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0daabca..e95ee7e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,6 +17,8 @@ COPY php.ini /usr/local/etc/php/php.ini RUN pecl install "xdebug-${XDEBUG_VERSION}"; \ docker-php-ext-enable xdebug +ENV XDEBUG_MODE=coverage + # Install PDO MySQL driver. RUN docker-php-ext-install \ pdo_mysql From eba8ebace0b9498fd72d82051ae955f2f4f2f4ef Mon Sep 17 00:00:00 2001 From: Michael Dinerstein Date: Thu, 11 Apr 2024 08:11:34 -0700 Subject: [PATCH 3/6] update: remove unnecessary codeception/codeception dep --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 387ccf1..2300567 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,6 @@ "wp-phpunit/wp-phpunit": "^6.3", "yoast/phpunit-polyfills": "^2.0", "phpunit/phpunit": "^9.6", - "codeception/codeception": "^5.1", "codeception/module-asserts": "*", "codeception/util-universalframework": "*", "codeception/module-rest": "*", From e9d179c92b381efd584cee8cad22724b955dd747 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 25 Apr 2024 16:24:55 -0400 Subject: [PATCH 4/6] devops: unneeded dependencies removed --- .github/workflows/continous-integration.yml | 23 ++++++++++--- composer.json | 11 ++----- src/TestCase/WPGraphQLTestCommon.php | 36 --------------------- 3 files changed, 22 insertions(+), 48 deletions(-) diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml index 00b7ba8..10305f8 100644 --- a/.github/workflows/continous-integration.yml +++ b/.github/workflows/continous-integration.yml @@ -32,14 +32,29 @@ jobs: php-version: ${{ matrix.php }} extensions: json, mbstring - - name: Install Dependencies - run: composer install + - name: Install WP PHPUnit Dependencies + run: | + composer install --ignore-platform-reqs + composer require wp-phpunit/wp-phpunit \ + yoast/phpunit-polyfills \ + phpunit/phpunit:^9.6 \ + wp-phpunit/wp-phpunit \ + + - name: Run PHPUnit Tests w/ Docker. + run: composer run-phpunit -- -- --coverage-text + + - name: Install WPBrowser Dependencies + run: | + composer install --ignore-platform-reqs + composer require codeception/module-asserts:* \ + codeception/util-universalframework:* \ + codeception/module-rest:* \ + lucatume/wp-browser:^3.1 --ignore-platform-reqs - name: Run Codeception Tests w/ Docker. run: composer run-codeception -- -- --coverage --coverage-xml - - name: Run PHPUnit Tests w/ Docker. - run: composer run-phpunit -- -- --coverage-text + - name: Push Codecoverage to Coveralls.io env: diff --git a/composer.json b/composer.json index 2300567..f8c4ac4 100644 --- a/composer.json +++ b/composer.json @@ -27,13 +27,6 @@ "squizlabs/php_codesniffer": "^3.5", "automattic/vipwpcs": "^2.3", "wp-coding-standards/wpcs": "^2.3", - "wp-phpunit/wp-phpunit": "^6.3", - "yoast/phpunit-polyfills": "^2.0", - "phpunit/phpunit": "^9.6", - "codeception/module-asserts": "*", - "codeception/util-universalframework": "*", - "codeception/module-rest": "*", - "lucatume/wp-browser": "^4.1", "php-coveralls/php-coveralls": "2.4.3" }, "scripts": { @@ -54,7 +47,9 @@ "codeception/util-universalframework": "Needed for \\Tests\\WPGraphQL\\TestCase\\WPGraphQLTestcase to work.", "codeception/module-rest": "Needed for \\Tests\\WPGraphQL\\TestCase\\WPGraphQLTestcase to work.", "lucatume/wp-browser": "Needed for \\Tests\\WPGraphQL\\TestCase\\WPGraphQLTestcase to work.", - "wp-phpunit/wp-phpunit": "Needed for \\Tests\\WPGraphQL\\TestCase\\WPGraphQLUnitTestcase to work." + "phpunit/phpunit": "Needed for \\Tests\\WPGraphQL\\TestCase\\WPGraphQLUnitTestcase to work.", + "wp-phpunit/wp-phpunit": "Needed for \\Tests\\WPGraphQL\\TestCase\\WPGraphQLUnitTestcase to work.", + "yoast/phpunit-polyfills": "Needed for \\Tests\\WPGraphQL\\TestCase\\WPGraphQLUnitTestcase to work." }, "config": { "allow-plugins": { diff --git a/src/TestCase/WPGraphQLTestCommon.php b/src/TestCase/WPGraphQLTestCommon.php index 73eff47..ca8dffa 100644 --- a/src/TestCase/WPGraphQLTestCommon.php +++ b/src/TestCase/WPGraphQLTestCommon.php @@ -836,24 +836,6 @@ protected static function endsWith( $needle, $haystack ) { return ( substr( $haystack, -$len ) === $needle ); } - /** - * Wrapper for IsTrue constraint. - * - * @return IsTrue - */ - public static function isTrue(): IsTrue { - return new IsTrue; - } - - /** - * Wrapper for IsEmpty constraint. - * - * @return IsEmpty - */ - public static function isEmpty(): IsEmpty { - return new IsEmpty; - } - /** * Wrapper for IsEqual constraint. * @@ -875,22 +857,4 @@ public static function isEqual( $value ): IsEqual { public static function contains( $value ): TraversableContainsIdentical { return new TraversableContainsIdentical( $value ); } - - /** - * Wrapper for IsNull constraint. - * - * @return IsNull - */ - public static function isNull(): IsNull { - return new IsNull; - } - - /** - * Wrapper for LogicalNot constraint. - * - * @return LogicalNot - */ - public static function logicalNot( Constraint $last_constraint ): LogicalNot { - return new LogicalNot( $last_constraint ); - } } From 525e16940fc36141f7169ba9dfe12f1599938d19 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 25 Apr 2024 16:32:24 -0400 Subject: [PATCH 5/6] devops: Coveralls configurations updated --- .github/workflows/continous-integration.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml index 10305f8..c1ed361 100644 --- a/.github/workflows/continous-integration.yml +++ b/.github/workflows/continous-integration.yml @@ -58,12 +58,10 @@ jobs: - name: Push Codecoverage to Coveralls.io env: - COVERALLS_RUN_LOCALLY: 1 - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | docker-compose run --rm \ --workdir=/var/www/html/wp-content/plugins/wp-graphql-testcase \ --user $(id -u) \ - -e COVERALLS_RUN_LOCALLY=1 -e COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN \ wordpress \ vendor/bin/php-coveralls -v From fd55bab98e57acaf31442912131ba10576cc8420 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 25 Apr 2024 16:35:21 -0400 Subject: [PATCH 6/6] devops: Coveralls configurations updated --- .github/workflows/continous-integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml index c1ed361..24fb8f9 100644 --- a/.github/workflows/continous-integration.yml +++ b/.github/workflows/continous-integration.yml @@ -63,5 +63,6 @@ jobs: docker-compose run --rm \ --workdir=/var/www/html/wp-content/plugins/wp-graphql-testcase \ --user $(id -u) \ + -e COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN \ wordpress \ vendor/bin/php-coveralls -v