mirror of
git://develop.git.wordpress.org/
synced 2025-04-09 14:42:05 +02:00
Build/Test Tools: Check if the WordPress Importer plugin is installed in test bootstrap.
If a hard requirement for the test suite is not fulfilled, running the tests should be blocked from the test bootstrap. A test should only fail when it doesn't produce the expected result. Since the WordPress Importer plugin is considered a hard requirement for the test suite at this time, this commit moves the check whether the plugin is installed from individual tests to the test bootstrap. Includes defining a global constant for the path to the file for reuse in the tests. Reference: [https://make.wordpress.org/core/handbook/contribute/git/#unit-tests Core Contributor Handbook: The Code Repository (Git): Unit Tests]. Follow-up to [40531], [40532], [41090], [41169], [48592], [49535], [49571]. Props jrf, hellofromTonya. See #61530. git-svn-id: https://develop.svn.wordpress.org/trunk@59085 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ec80646878
commit
60a66de6ec
@ -214,6 +214,13 @@ tests_reset__SERVER();
|
||||
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
|
||||
define( 'DIR_TESTDATA', __DIR__ . '/../data' );
|
||||
define( 'DIR_TESTROOT', realpath( dirname( __DIR__ ) ) );
|
||||
define( 'IMPORTER_PLUGIN_FOR_TESTS', DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' );
|
||||
|
||||
if ( ! file_exists( IMPORTER_PLUGIN_FOR_TESTS ) ) {
|
||||
echo 'The test suite requires the WordPress Importer plugin to be available in the `/data/plugins/` directory.'
|
||||
. ' See: https://make.wordpress.org/core/handbook/contribute/git/#unit-tests' . PHP_EOL,
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
define( 'WP_LANG_DIR', realpath( DIR_TESTDATA . '/languages' ) );
|
||||
|
||||
|
@ -7,6 +7,8 @@ require_once __DIR__ . '/base.php';
|
||||
*/
|
||||
class Tests_Import_Import extends WP_Import_UnitTestCase {
|
||||
public function set_up() {
|
||||
global $wpdb;
|
||||
|
||||
parent::set_up();
|
||||
|
||||
if ( ! defined( 'WP_IMPORTING' ) ) {
|
||||
@ -19,13 +21,8 @@ class Tests_Import_Import extends WP_Import_UnitTestCase {
|
||||
|
||||
add_filter( 'import_allow_create_users', '__return_true' );
|
||||
|
||||
if ( ! file_exists( DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' ) ) {
|
||||
$this->fail( 'This test requires the WordPress Importer plugin to be installed in the test suite. See: https://make.wordpress.org/core/handbook/contribute/git/#unit-tests' );
|
||||
}
|
||||
require_once IMPORTER_PLUGIN_FOR_TESTS;
|
||||
|
||||
require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
|
||||
|
||||
global $wpdb;
|
||||
// Crude but effective: make sure there's no residual data in the main tables.
|
||||
foreach ( array( 'posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta' ) as $table ) {
|
||||
$wpdb->query( "DELETE FROM {$wpdb->$table}" );
|
||||
|
@ -17,11 +17,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
|
||||
define( 'WP_LOAD_IMPORTERS', true );
|
||||
}
|
||||
|
||||
if ( ! file_exists( DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' ) ) {
|
||||
$this->fail( 'This test requires the WordPress Importer plugin to be installed in the test suite. See: https://make.wordpress.org/core/handbook/contribute/git/#unit-tests' );
|
||||
}
|
||||
|
||||
require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
|
||||
require_once IMPORTER_PLUGIN_FOR_TESTS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,11 +19,7 @@ class Tests_Import_Postmeta extends WP_Import_UnitTestCase {
|
||||
define( 'WP_LOAD_IMPORTERS', true );
|
||||
}
|
||||
|
||||
if ( ! file_exists( DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' ) ) {
|
||||
$this->fail( 'This test requires the WordPress Importer plugin to be installed in the test suite. See: https://make.wordpress.org/core/handbook/contribute/git/#unit-tests' );
|
||||
}
|
||||
|
||||
require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
|
||||
require_once IMPORTER_PLUGIN_FOR_TESTS;
|
||||
}
|
||||
|
||||
public function test_serialized_postmeta_no_cdata() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user