Skip to content

Commit 79ecc3a

Browse files
author
costdev
committed
Add tests for ::mtime().
1 parent c608af4 commit 79ecc3a

File tree

1 file changed

+49
-0
lines changed
  • tests/phpunit/tests/filesystem/direct

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Tests for the WP_Filesystem_Direct::mtime() method.
4+
*
5+
* @package WordPress
6+
*/
7+
8+
require_once __DIR__ . '/base.php';
9+
10+
/**
11+
* @group admin
12+
* @group filesystem
13+
* @group filesystem-direct
14+
*
15+
* @covers WP_Filesystem_Direct::mtime
16+
*/
17+
class Tests_Filesystem_WpFilesystemDirect_Mtime extends WP_Filesystem_Direct_UnitTestCase {
18+
19+
/**
20+
* Tests that `WP_Filesystem_Direct::mtime()`
21+
* returns the correct result for a path.
22+
*
23+
* @ticket 57774
24+
*
25+
* @dataProvider data_paths_that_do_not_exist
26+
* @dataProvider data_paths_that_exist
27+
*
28+
* @param string $path The path.
29+
* @param bool $expected The expected result.
30+
*/
31+
public function test_should_determine_file_modified_time( $path, $expected ) {
32+
$result = self::$filesystem->mtime( self::$file_structure['test_dir']['path'] . $path );
33+
$has_mtime = false !== $result;
34+
35+
$this->assertSame(
36+
$expected,
37+
$has_mtime,
38+
'The result is not the same.'
39+
);
40+
41+
if ( $expected ) {
42+
$this->assertIsInt(
43+
$result,
44+
'The mtime is not an integer.'
45+
);
46+
}
47+
}
48+
49+
}

0 commit comments

Comments
 (0)