/** * Test that putting contents in a directory fails. * * @since 0.1.0 */ public function test_put_dir_contents() { $this->assertTrue($this->mock_fs->add_file('/test', array('type' => 'dir'))); $this->assertFalse($this->fs->put_contents('/test', 'Test.', 0600)); $this->assertEquals('dir', $this->mock_fs->get_file_attr('/test', 'type')); $this->assertInstanceOf('stdClass', $this->mock_fs->get_file_attr('/test', 'contents')); $this->assertEquals(0755, $this->mock_fs->get_file_attr('/test', 'mode')); }
/** * Test moving a file to a existing destination file. * * @since 0.1.0 */ public function test_move_file_to_existing_destination_file() { $this->assertTrue($this->mock->add_file('/test.txt', array('contents' => 'testing'))); $this->assertTrue($this->mock->exists('/test.txt')); $this->assertEquals('testing', $this->mock->get_file_attr('/test.txt', 'contents')); $this->assertTrue($this->mock->add_file('/a.txt', array('contents' => 'abc'))); $this->assertTrue($this->mock->exists('/a.txt')); $this->assertEquals('abc', $this->mock->get_file_attr('/a.txt', 'contents')); $this->assertTrue($this->mock->move('/test.txt', '/a.txt')); $this->assertFalse($this->mock->exists('/test.txt')); $this->assertTrue($this->mock->exists('/a.txt')); $this->assertEquals('testing', $this->mock->get_file_attr('/a.txt', 'contents')); }
/** * @since 0.1.0 */ public function size($file) { return self::$mock->get_file_attr($file, 'size'); }