From c4b4a6ba3ae1f816eb79486011afdab8c96721e9 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Tue, 20 Aug 2024 12:30:48 +0530 Subject: [PATCH 1/2] fix: phpunit gh action failing --- .github/workflows/test-php.yml | 4 ++-- .gitignore | 1 + composer.json | 3 ++- tests/bootstrap.php | 5 +++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml index bba75f0..e465cd8 100644 --- a/.github/workflows/test-php.yml +++ b/.github/workflows/test-php.yml @@ -47,7 +47,7 @@ jobs: - name: Setup PHP version uses: shivammathur/setup-php@v2 with: - php-version: '7.1' + php-version: '7.2' extensions: simplexml, mysql tools: phpunit-polyfills - name: Checkout source code @@ -69,4 +69,4 @@ jobs: - name: Install composer run: composer install --prefer-dist --no-progress --no-suggest - name: Run phpunit - run: phpunit \ No newline at end of file + run: composer run-script phpunit \ No newline at end of file diff --git a/.gitignore b/.gitignore index db5ba8c..f14c7c2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ assets/js/build languages/fork.pot .DS_Store +phpunit.result.cache \ No newline at end of file diff --git a/composer.json b/composer.json index 7ba9ebe..e1e878d 100644 --- a/composer.json +++ b/composer.json @@ -51,6 +51,7 @@ "format": "phpcbf --standard=phpcs.xml --report-summary --report-source -s --runtime-set testVersion 7.0- ", "phpcs": "phpcs --standard=phpcs.xml -s --runtime-set testVersion 7.0-", "lint": "composer run-script phpcs", - "phpcs-i": "phpcs -i" + "phpcs-i": "phpcs -i", + "phpunit": "phpunit" } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 93b5c06..ca24311 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,6 +8,11 @@ define( 'FORK_IGNORE_SOURCE_CHECK', true ); $_tests_dir = getenv( 'WP_TESTS_DIR' ); + +if ( class_exists( '\Yoast\PHPUnitPolyfills\Autoload' ) === false ) { + require_once dirname( dirname( __FILE__ ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php'; +} + if ( ! $_tests_dir ) { $_tests_dir = '/tmp/wordpress-tests-lib'; } From 6741dfeaeadc49dbdf360f9adde2c9962b4455c7 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Tue, 20 Aug 2024 12:31:35 +0530 Subject: [PATCH 2/2] fix: debug error caused by Design Pack notice --- assets/js/src/design-pack-notice.js | 4 +++- inc/Admin.php | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/src/design-pack-notice.js b/assets/js/src/design-pack-notice.js index 764e811..9fcf7a2 100644 --- a/assets/js/src/design-pack-notice.js +++ b/assets/js/src/design-pack-notice.js @@ -2,7 +2,9 @@ import { createRoot } from '@wordpress/element'; import DesignPackNotice from './components/DesignPackNotice'; -const container = document.getElementById( 'fork-design-pack-notice' ); +const container = document.createElement( 'div' ); +container.id = 'fork-design-pack-notice'; +document.body.appendChild( container ); if ( container ) { createRoot( container ).render( ); diff --git a/inc/Admin.php b/inc/Admin.php index 211005d..cae9848 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -73,8 +73,6 @@ public function add_fse_design_pack_notice() { ), 'designPackNoticeData' ); - - echo '
'; } /**