mirror of
git://develop.git.wordpress.org/
synced 2025-01-16 20:38:35 +01:00
Tests/Build tools: Only fail importer tests if plugin is missing.
Reverts an earlier change to the test suite in which the PHPUnit tests could not run if the importer plugin was not available. This update allows the test suite to run and will fail importer tests if the plugin is not available. Follow up to r59085. Props peterwilsoncc, azaozz. See #62325. git-svn-id: https://develop.svn.wordpress.org/trunk@59326 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d1e0c0f9c6
commit
023af2111b
@ -216,12 +216,6 @@ 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 ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! 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' ) );
|
||||
|
||||
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
|
||||
|
@ -1,6 +1,19 @@
|
||||
<?php
|
||||
|
||||
abstract class WP_Import_UnitTestCase extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Require the WordPress Importer plugin.
|
||||
*
|
||||
* Fails the test if the plugin is not installed.
|
||||
*/
|
||||
protected function require_importer() {
|
||||
if ( ! file_exists( IMPORTER_PLUGIN_FOR_TESTS ) ) {
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a WXR file.
|
||||
*
|
||||
@ -21,6 +34,8 @@ abstract class WP_Import_UnitTestCase extends WP_UnitTestCase {
|
||||
* @param bool $fetch_files Whether or not do download remote attachments
|
||||
*/
|
||||
protected function _import_wp( $filename, $users = array(), $fetch_files = true ) {
|
||||
$this->require_importer();
|
||||
|
||||
$importer = new WP_Import();
|
||||
$file = realpath( $filename );
|
||||
|
||||
|
@ -21,7 +21,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase {
|
||||
|
||||
add_filter( 'import_allow_create_users', '__return_true' );
|
||||
|
||||
require_once IMPORTER_PLUGIN_FOR_TESTS;
|
||||
$this->require_importer();
|
||||
|
||||
// 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 ) {
|
||||
|
@ -17,7 +17,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase {
|
||||
define( 'WP_LOAD_IMPORTERS', true );
|
||||
}
|
||||
|
||||
require_once IMPORTER_PLUGIN_FOR_TESTS;
|
||||
$this->require_importer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ class Tests_Import_Postmeta extends WP_Import_UnitTestCase {
|
||||
define( 'WP_LOAD_IMPORTERS', true );
|
||||
}
|
||||
|
||||
require_once IMPORTER_PLUGIN_FOR_TESTS;
|
||||
$this->require_importer();
|
||||
}
|
||||
|
||||
public function test_serialized_postmeta_no_cdata() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user