forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.php
More file actions
44 lines (37 loc) · 1.33 KB
/
base.php
File metadata and controls
44 lines (37 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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->assertInstanceOf( 'WP_Filesystem_MockFS', $wp_filesystem );
$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 );
}
}