Skip to content

Commit

Permalink
Create cache dir
Browse files Browse the repository at this point in the history
  • Loading branch information
wppunk committed Feb 28, 2020
1 parent 50d12cb commit 12bfe0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions classes/class-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ function ( $k, $v ) {
);
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
$filesystem = $this->WP_Filesystem();
if ( ! $filesystem->exists( dirname( $this->map_file ) ) ) {
wp_mkdir_p( dirname( $this->map_file ) );
}
$filesystem->put_contents( $this->map_file, '<?php return [' . $map . '];' );
}

Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/tests/class-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ public function test_update_invalid_cache() {
public function test_save() {
Mockery::mock( 'WP_Filesystem_Base' );
$wp_filesystem = Mockery::mock( 'overload:WP_Filesystem_Direct' );
$wp_filesystem->shouldReceive( 'exists' )->once()->andReturn( false );
$wp_filesystem->shouldReceive( 'put_contents' )->once();
WP_Mock::userFunction( 'WP_Filesystem', [ 'times' => 1 ] );
WP_Mock::userFunction( 'wp_mkdir_p', [ 'times' => 1 ] );

$cache = new Cache();
$cache->update( '\Prefix\Autoload_Success_1', __DIR__ . '/../classes/path-1/prefix/class-autoload-success-1.php' );
Expand Down

0 comments on commit 12bfe0e

Please sign in to comment.