Skip to content

Commit

Permalink
Fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Jan 30, 2025
1 parent 85efc2d commit 31e1f18
Showing 1 changed file with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Test class covering \WP_Rocket\Engine\Common\Cache\FilesystemCache::is_accessible
*/
class TestIsAccessible extends TestCase {
class Test_IsAccessible extends TestCase {
protected $root_folder;
protected $filesystem;
protected $filesystemcache;
Expand All @@ -27,17 +27,35 @@ public function set_up() {

/**
* @dataProvider configTestData
* @throws \Exception
*/
public function testShouldReturnAsExpected( $config, $expected ) {
Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\when('get_current_blog_id')->justReturn( 1 );
Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\when('get_current_blog_id')->justReturn( 1 );

$this->filesystem->shouldReceive('exists')->with($expected['path'])->andReturn($config['exists']);
if( ! $config['exists']) {
Functions\expect('rocket_mkdir_p')->with($expected['path'], $this->filesystem);
}
$this->filesystem->shouldReceive('is_writable')->with($expected['path'])->andReturn($config['is_writable']);
$base_path = $config['root'] . $this->root_folder;
$root_path = $expected['path'];


$this->filesystem->shouldReceive('exists')
->with($base_path)
->andReturn($config['exists']);

if( ! $config['exists']) {
Functions\expect('rocket_mkdir_p')->with($base_path, $this->filesystem);
}

$this->filesystem->shouldReceive('exists')
->with($root_path)
->andReturn($config['exists']);

if (!$config['exists']) {
Functions\expect('rocket_mkdir_p')
->with($root_path, $this->filesystem);
}

$this->filesystem->shouldReceive('is_writable')->with($root_path)->andReturn($config['is_writable']);

$this->assertSame($expected['output'], $this->filesystemcache->is_accessible());
$this->assertSame($expected['output'], $this->filesystemcache->is_accessible());
}
}

0 comments on commit 31e1f18

Please sign in to comment.