mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
This avoids the performance overhead of the function call every time `dirname( __FILE__ )` was used instead of `__DIR__`. This commit also includes: * Removing unnecessary parentheses from `include`/`require` statements. These are language constructs, not function calls. * Replacing `include` statements for several files with `require_once`, for consistency: * `wp-admin/admin-header.php` * `wp-admin/admin-footer.php` * `wp-includes/version.php` Props ayeshrajans, desrosj, valentinbora, jrf, joostdevalk, netweb. Fixes #48082. git-svn-id: https://develop.svn.wordpress.org/trunk@47198 602fd350-edb4-49c9-b593-d223f7449a82
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This class is designed to make use of MockFS, a Virtual in-memory filesystem compatible with WP_Filesystem
|
|
*/
|
|
abstract class WP_Filesystem_UnitTestCase extends WP_UnitTestCase {
|
|
function setUp() {
|
|
parent::setUp();
|
|
add_filter( 'filesystem_method_file', array( $this, 'filter_abstraction_file' ) );
|
|
add_filter( 'filesystem_method', array( $this, 'filter_fs_method' ) );
|
|
WP_Filesystem();
|
|
}
|
|
|
|
function tearDown() {
|
|
global $wp_filesystem;
|
|
remove_filter( 'filesystem_method_file', array( $this, 'filter_abstraction_file' ) );
|
|
remove_filter( 'filesystem_method', array( $this, 'filter_fs_method' ) );
|
|
unset( $wp_filesystem );
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
function filter_fs_method( $method ) {
|
|
return 'MockFS';
|
|
}
|
|
function filter_abstraction_file( $file ) {
|
|
return dirname( dirname( __DIR__ ) ) . '/includes/mock-fs.php';
|
|
}
|
|
|
|
function test_is_MockFS_sane() {
|
|
global $wp_filesystem;
|
|
$this->assertTrue( is_a( $wp_filesystem, 'WP_Filesystem_MockFS' ) );
|
|
|
|
$wp_filesystem->init( '/' );
|
|
|
|
// Test creation/exists checks.
|
|
$this->assertFalse( $wp_filesystem->is_dir( '/test/' ) );
|
|
$wp_filesystem->mkdir( '/test' );
|
|
$this->assertTrue( $wp_filesystem->exists( '/test' ) );
|
|
$this->assertTrue( $wp_filesystem->is_dir( '/test/' ) );
|
|
$this->assertFalse( $wp_filesystem->is_file( '/test' ) );
|
|
// $this->assertFalse( true );
|
|
}
|
|
}
|