From 718aa78c4e73a6653f3359d0e545d0e2777cffe3 Mon Sep 17 00:00:00 2001 From: Pollora maintainer Date: Sat, 21 Nov 2026 14:44:00 +0100 Subject: [PATCH 1/2] ci: pilot the optional WordPress integration job (do not merge) --- .github/workflows/harness.yml | 4 ++- phpunit.integration.xml | 21 ++++++++++++ tests/Integration/WordPressLoadedTest.php | 38 ++++++++++++++++++++++ tests/Integration/bootstrap.php | 39 +++++++++++++++++++++++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 phpunit.integration.xml create mode 100644 tests/Integration/WordPressLoadedTest.php create mode 100644 tests/Integration/bootstrap.php diff --git a/.github/workflows/harness.yml b/.github/workflows/harness.yml index fd3f280..fcfa63a 100644 --- a/.github/workflows/harness.yml +++ b/.github/workflows/harness.yml @@ -14,6 +14,8 @@ permissions: {} jobs: harness: - uses: Pollora/harness/.github/workflows/php-package.yml@v0.1.34 + uses: Pollora/harness/.github/workflows/php-package.yml@main + with: + wordpress-integration: tests/Integration permissions: contents: read diff --git a/phpunit.integration.xml b/phpunit.integration.xml new file mode 100644 index 0000000..4ddd2e7 --- /dev/null +++ b/phpunit.integration.xml @@ -0,0 +1,21 @@ + + + + + + tests/Integration + + + diff --git a/tests/Integration/WordPressLoadedTest.php b/tests/Integration/WordPressLoadedTest.php new file mode 100644 index 0000000..57152c7 --- /dev/null +++ b/tests/Integration/WordPressLoadedTest.php @@ -0,0 +1,38 @@ +toBeTrue() + ->and(defined('ABSPATH'))->toBeTrue() + ->and(get_bloginfo('name'))->not->toBe(''); +}); + +it('talks to the database of the installed site', function (): void { + global $wpdb; + + expect($wpdb)->toBeInstanceOf(wpdb::class) + ->and(get_option('siteurl'))->toBeString()->not->toBe('') + ->and(is_blog_installed())->toBeTrue(); +}); + +it('fires the real hooks', function (): void { + $seen = 0; + add_action('pollora_harness_probe', function () use (&$seen): void { + $seen++; + }); + + do_action('pollora_harness_probe'); + + expect($seen)->toBe(1) + ->and(has_action('pollora_harness_probe'))->toBeTrue(); +}); + +it('registers post meta, which fails without WordPress', function (): void { + expect(register_post_meta('post', 'pollora_harness_meta', ['type' => 'string', 'single' => true, 'show_in_rest' => true]))->toBeTrue() + ->and(registered_meta_key_exists('post', 'pollora_harness_meta', 'post'))->toBeTrue(); +}); diff --git a/tests/Integration/bootstrap.php b/tests/Integration/bootstrap.php new file mode 100644 index 0000000..c70dcab --- /dev/null +++ b/tests/Integration/bootstrap.php @@ -0,0 +1,39 @@ + Date: Sat, 21 Nov 2026 14:46:29 +0100 Subject: [PATCH 2/2] ci: pilot with the corrected template and export-ignore (do not merge) --- .gitattributes | 1 + tests/Integration/WordPressLoadedTest.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 625b81a..399b9bb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,3 +14,4 @@ /rector.php export-ignore /renovate.json export-ignore /tests export-ignore +/phpunit.integration.xml export-ignore diff --git a/tests/Integration/WordPressLoadedTest.php b/tests/Integration/WordPressLoadedTest.php index 57152c7..65397db 100644 --- a/tests/Integration/WordPressLoadedTest.php +++ b/tests/Integration/WordPressLoadedTest.php @@ -9,14 +9,15 @@ it('has loaded WordPress', function (): void { expect(function_exists('register_post_meta'))->toBeTrue() ->and(defined('ABSPATH'))->toBeTrue() - ->and(get_bloginfo('name'))->not->toBe(''); + ->and(get_bloginfo('name') !== '')->toBeTrue(); }); it('talks to the database of the installed site', function (): void { global $wpdb; expect($wpdb)->toBeInstanceOf(wpdb::class) - ->and(get_option('siteurl'))->toBeString()->not->toBe('') + ->and(get_option('siteurl'))->toBeString() + ->and(get_option('siteurl') !== '')->toBeTrue() ->and(is_blog_installed())->toBeTrue(); });