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/.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..65397db --- /dev/null +++ b/tests/Integration/WordPressLoadedTest.php @@ -0,0 +1,39 @@ +toBeTrue() + ->and(defined('ABSPATH'))->toBeTrue() + ->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() + ->and(get_option('siteurl') !== '')->toBeTrue() + ->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 @@ +