File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
tests/phpunit/tests/filesystem/wpFilesystemDirect Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Tests for the WP_Filesystem_Direct::get_contents() 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::get_contents
16+ */
17+ class Tests_Filesystem_WpFilesystemDirect_GetContents extends WP_Filesystem_Direct_UnitTestCase {
18+
19+ /**
20+ * Tests that `WP_Filesystem_Direct::get_contents()` gets the
21+ * contents of the provided $file.
22+ *
23+ * @ticket 57774
24+ */
25+ public function test_should_get_the_contents_of_a_file () {
26+ $ file = self ::$ file_structure ['visible_file ' ]['path ' ];
27+
28+ $ this ->assertSame (
29+ "Contents of a file. \r\nNext line of a file. \r\n" ,
30+ self ::$ filesystem ->get_contents ( $ file )
31+ );
32+ }
33+
34+ /**
35+ * Tests that `WP_Filesystem_Direct::get_contents()`
36+ * returns false for a file that does not exist.
37+ *
38+ * @ticket 57774
39+ *
40+ * @dataProvider data_paths_that_do_not_exist
41+ *
42+ * @param string $path The path.
43+ */
44+ public function test_should_return_false ( $ path ) {
45+ $ this ->assertFalse ( self ::$ filesystem ->get_contents ( self ::$ file_structure ['test_dir ' ]['path ' ] . $ path ) );
46+ }
47+
48+ }
You can’t perform that action at this time.
0 commit comments