Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fonts test files use Core approach #53856

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<testsuites>
<testsuite name="default">
<directory suffix="-test.php">./phpunit/</directory>
<directory suffix=".php">./phpunit/tests/</directory>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WordPress Core does it this way https://github.com/WordPress/wordpress-develop/blob/trunk/phpunit.xml.dist#L17.

I left the original <directory> directive on purpose to:

  • allow all other tests to run, until they are also moved into this Core specific tests directory.
  • avoid disruption in existing PRs.

</testsuite>
</testsuites>
<groups>
Expand Down
2 changes: 2 additions & 0 deletions phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
if ( ! defined( 'LOCAL_WP_ENVIRONMENT_TYPE' ) ) {
define( 'LOCAL_WP_ENVIRONMENT_TYPE', 'local' );
}
define( 'GUTENBERG_DIR_TESTDATA', __DIR__ . '/data/' );
define( 'GUTENBERG_DIR_TESTFIXTURES', __DIR__ . '/fixtures/' );
Comment on lines +24 to +25
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core uses DIR_TESTDATA to point to its tests' data directory. This is a constant that will need to be changed when merging tests into Core.

Could explore overwriting DIR_TESTDATA instead. But there may be some tests that truly need to use Core's data directory and contents.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a constant that will need to be changed when merging tests into Core.

I'm wondering if the necessity of renaming the constant should be documented somewhere.
I can't seem to find an appropriate page in the Gutenberg developer documentation where the requirement to rename the constant could be added.
Probably, considering adding a new phpunit/README.md file could be an option, similar to the README.md file in the lib/ folder.
What's your opinion on this matter, @hellofromtonya?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking @anton-vlasenko. I'm thinking about a separate follow-up PR that updates or adds a doc page for the Gutenberg handbook.

Why separate PR?
This PR is focused on only the fonts components, rather than all of the tests. A separate scope of work can be targeted at providing testing instructions and guidance for tests that are intended to be merged into Core. I suspect there's none currently available. Thus, the handbook/docs scope of work might be more involved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, we'll want to document the new @core-merge annotation with Core merge instructions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate scope of work can be targeted at providing testing instructions and guidance for tests that are intended to be merged into Core. I suspect there's none currently available. Thus, the handbook/docs scope of work might be more involved.

That's a good point, @hellofromtonya. I agree.
Doing it within the scope of another PR is fine with me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue for documenting the new @core-merge annotation: #54041


// Pretend that these are Core unit tests. This is needed so that
// wp_theme_has_theme_json() does not cache its return value between each test.
Expand Down
1 change: 1 addition & 0 deletions phpunit/multisite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<testsuites>
<testsuite name="default">
<directory suffix="-test.php">./</directory>
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<groups>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function set_up_before_class() {
parent::set_up_before_class();

if ( self::$requires_switch_theme_fixtures ) {
self::$theme_root = realpath( __DIR__ . '/../data/themedir1' );
self::$theme_root = realpath( GUTENBERG_DIR_TESTDATA . '/themedir1' );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';
require_once __DIR__ . '/bc-layer-tests-dataset.php';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../fonts-bc-layer-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../fonts-bc-layer-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/fonts-bc-layer-testcase.php';
require_once __DIR__ . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../fonts-bc-layer-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../fonts-bc-layer-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../fonts-bc-layer-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/wp-fonts-testcase.php';
require_once __DIR__ . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/wp-fonts-testcase.php';
require_once __DIR__ . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/wp-fonts-testcase.php';
require_once __DIR__ . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/wp-fonts-testcase.php';
require_once __DIR__ . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/wp-fonts-testcase.php';
require_once __DIR__ . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once __DIR__ . '/../../fixtures/mock-provider.php';
require_once dirname( __DIR__ ) . '/base.php';
require_once GUTENBERG_DIR_TESTFIXTURES . '/mock-provider.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once __DIR__ . '/../../fixtures/mock-provider.php';
require_once dirname( __DIR__ ) . '/base.php';
require_once GUTENBERG_DIR_TESTFIXTURES . '/mock-provider.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once __DIR__ . '/../../fixtures/mock-provider.php';
require_once dirname( __DIR__ ) . '/base.php';
require_once GUTENBERG_DIR_TESTFIXTURES . '/mock-provider.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/wp-fonts-testcase.php';
require_once __DIR__ . '/base.php';

/**
* @group fontsapi
Expand Down Expand Up @@ -155,7 +155,7 @@ public function data_get_css_print_styles() {
* `wp-content/themes/` directory to ensure consistency when running tests.
*/
private function set_up_theme() {
$this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
$this->theme_root = realpath( GUTENBERG_DIR_TESTDATA . '/themedir1' );
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
$GLOBALS['wp_theme_directories'] = array( $this->theme_root );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* Test WP_Fonts_Resolver::add_missing_fonts_to_theme_json().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* Test WP_Fonts_Resolver::register_fonts_from_theme_json().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/../wp-fonts-testcase.php';
require_once dirname( __DIR__ ) . '/base.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/wp-fonts-testcase.php';
require_once __DIR__ . '/../fixtures/mock-provider.php';
require_once __DIR__ . '/base.php';
require_once GUTENBERG_DIR_TESTFIXTURES . '/mock-provider.php';

/**
* @group fontsapi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @subpackage Fonts API
*/

require_once __DIR__ . '/wp-fonts-testcase.php';
require_once __DIR__ . '/../fixtures/mock-provider.php';
require_once __DIR__ . '/base.php';
require_once GUTENBERG_DIR_TESTFIXTURES . '/mock-provider.php';

/**
* @group fontsapi
Expand Down
Loading