Skip to content

Commit

Permalink
Make fonts test files use Core approach (#53856)
Browse files Browse the repository at this point in the history
* Make Fonts test files use Core approach.
* Moves the files into phpunit/tests/ directory to match Core.
* Removes the `-test.php` suffix from each test file.
* Adds the directive to find the test files in phpunit/tests/ (to match how Core does it).
* Adds GUTENBERG_DIR_TESTDATA and GUTENBERG_DIR_TESTFIXTURES constants to make it easier on tests to point to these locations.
* Rename testcase to base.php
  • Loading branch information
hellofromtonya authored Aug 22, 2023
1 parent 4b0bb9a commit f0ff5f5
Show file tree
Hide file tree
Showing 64 changed files with 54 additions and 50 deletions.
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>
</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/' );

// 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

0 comments on commit f0ff5f5

Please sign in to comment.