Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that we create background-css folder correctly #7261

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions inc/Engine/Common/Cache/FilesystemCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ public function generate_path( string $url ): string {
* @return bool
*/
public function is_accessible(): bool {
$base_path = $this->get_base_path();
if ( ! $this->filesystem->exists( $base_path ) ) {
rocket_mkdir_p( $base_path, $this->filesystem );
}
$root_path = $this->get_root_path();
if ( ! $this->filesystem->exists( $root_path ) ) {
rocket_mkdir_p( $root_path, $this->filesystem );
Expand Down
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());
}
}
Loading