WordPress.org

Make WordPress Core

Changeset 42741


Ignore:
Timestamp:
02/25/2018 06:06:49 PM (4 months ago)
Author:
adamsilverstein
Message:

Unit Tests: add a DIR_TESTROOT constant to avoid relative paths.

Fix an issue that prevents tests from running correctly when run outside their normal context.

Props PressLabs, johnbillion.
Fixes #40071.

Location:
trunk/tests/phpunit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/bootstrap.php

    r42724 r42741  
    3737define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
    3838define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' );
     39define( 'DIR_TESTROOT', realpath( dirname( dirname( __FILE__ ) ) ) );
    3940
    4041define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' );
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r42724 r42741  
    396396        if ( ! is_multisite() && version_compare( PHP_VERSION, '5.4', '>=' ) ) {
    397397            // Save the route object for QUnit tests.
    398             $file = './tests/qunit/fixtures/wp-api-generated.js';
     398            $file = dirname( DIR_TESTROOT ) . '/qunit/fixtures/wp-api-generated.js';
    399399            file_put_contents( $file, $mocked_responses );
    400400        }
Note: See TracChangeset for help on using the changeset viewer.