Make WordPress Core

Changeset 59327


Ignore:
Timestamp:
10/30/2024 11:45:53 PM (5 weeks ago)
Author:
peterwilsoncc
Message:

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.

Merges [59326] to the 6.7 branch.

Props peterwilsoncc, azaozz.
See #62325.

Location:
branches/6.7
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/6.7

  • branches/6.7/tests/phpunit/includes/bootstrap.php

    r59086 r59327  
    217217define( 'IMPORTER_PLUGIN_FOR_TESTS', DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' );
    218218
    219 if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! file_exists( IMPORTER_PLUGIN_FOR_TESTS ) ) {
    220     echo 'The test suite requires the WordPress Importer plugin to be available in the `/data/plugins/` directory.'
    221         . ' See: https://make.wordpress.org/core/handbook/contribute/git/#unit-tests' . PHP_EOL,
    222     exit( 1 );
    223 }
    224 
    225219define( 'WP_LANG_DIR', realpath( DIR_TESTDATA . '/languages' ) );
    226220
  • branches/6.7/tests/phpunit/tests/import/base.php

    r56549 r59327  
    22
    33abstract class WP_Import_UnitTestCase extends WP_UnitTestCase {
     4
     5    /**
     6     * Require the WordPress Importer plugin.
     7     *
     8     * Fails the test if the plugin is not installed.
     9     */
     10    protected function require_importer() {
     11        if ( ! file_exists( IMPORTER_PLUGIN_FOR_TESTS ) ) {
     12            $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' );
     13        }
     14        require_once IMPORTER_PLUGIN_FOR_TESTS;
     15    }
     16
    417    /**
    518     * Import a WXR file.
     
    2235     */
    2336    protected function _import_wp( $filename, $users = array(), $fetch_files = true ) {
     37        $this->require_importer();
     38
    2439        $importer = new WP_Import();
    2540        $file     = realpath( $filename );
  • branches/6.7/tests/phpunit/tests/import/import.php

    r59085 r59327  
    2222        add_filter( 'import_allow_create_users', '__return_true' );
    2323
    24         require_once IMPORTER_PLUGIN_FOR_TESTS;
     24        $this->require_importer();
    2525
    2626        // Crude but effective: make sure there's no residual data in the main tables.
  • branches/6.7/tests/phpunit/tests/import/parser.php

    r59168 r59327  
    1818        }
    1919
    20         require_once IMPORTER_PLUGIN_FOR_TESTS;
     20        $this->require_importer();
    2121    }
    2222
  • branches/6.7/tests/phpunit/tests/import/postmeta.php

    r59085 r59327  
    2020        }
    2121
    22         require_once IMPORTER_PLUGIN_FOR_TESTS;
     22        $this->require_importer();
    2323    }
    2424
Note: See TracChangeset for help on using the changeset viewer.