Skip to content

Commit

Permalink
fix old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wordpressfan committed Jan 20, 2025
1 parent 7c13eb6 commit fefa3b0
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
'expected' => [
'output' => true,
'path' => '/cache/background-css/'
'path' => '/cache/background-css/1/'
]
],
'notExistsShouldReturnFalse' => [
Expand All @@ -17,7 +17,7 @@
],
'expected' => [
'output' => true,
'path' => '/cache/background-css/'
'path' => '/cache/background-css/1/'
]
],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]
],
'expected' => [
'path' => '/cache/background-css/example.org/blog/test/file.css',
'path' => '/cache/background-css/1/example.org/blog/test/file.css',
'output' => true
]
],
Expand All @@ -30,7 +30,7 @@
]
],
'expected' => [
'path' => '/cache/background-css/example.org/blog/test',
'path' => '/cache/background-css/1/example.org/blog/test',
'output' => true
]
],
Expand All @@ -47,7 +47,7 @@
]
],
'expected' => [
'path' => '/cache/background-css/example.org/blog/test/file.css',
'path' => '/cache/background-css/1/example.org/blog/test/file.css',
'output' => false
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
],
],
'is_dir' => [
'/cache/background-css/example.org/blog/test/file.css' => false,
'/cache/background-css/example.org/blog/test' => true,
'/cache/background-css/1/example.org/blog/test/file.css' => false,
'/cache/background-css/1/example.org/blog/test' => true,
],
'exists' => [
'/cache/background-css/example.org/blog/test/file.css' => true,
'/cache/background-css/example.org/blog/test' => true,
'/cache/background-css/1/example.org/blog/test/file.css' => true,
'/cache/background-css/1/example.org/blog/test' => true,
],
],
'expected' => [
Expand All @@ -50,11 +50,11 @@
],
],
'is_dir' => [
'/cache/background-css/example.org/blog/test/file.css' => false,
'/cache/background-css/1/example.org/blog/test/file.css' => false,
],
'exists' => [
'/cache/background-css/example.org/blog/test/file.css' => true,
'/cache/background-css/example.org/blog/test' => false,
'/cache/background-css/1/example.org/blog/test/file.css' => true,
'/cache/background-css/1/example.org/blog/test' => false,
],
],
'expected' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
],
'expected' => [
'url' => 'http://example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'output' => 'http://example.org/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => 'http://example.org/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'home_url' => 'http://example.org',
]
],
Expand All @@ -43,8 +43,8 @@
],
'expected' => [
'url' => '/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'output' => 'http://example.org/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => 'http://example.org/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'home_url' => 'http://example.org',
]
],
Expand All @@ -67,8 +67,8 @@
],
'expected' => [
'url' => 'http://example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'output' => 'http://example.org/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => 'http://example.org/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'home_url' => 'http://example.org',
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
'expected' => [
'url' => 'http://example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => 'content'
]
],
Expand All @@ -34,7 +34,7 @@
],
'expected' => [
'url' => 'http://example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => null
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
'root' => '/var/html/wp-content/cache',
'home_url' => 'http://example.org',
'exists' => [
'/var/html/wp-content/cache/background-css/example.org/blog/test/file.css' => true,
'/var/html/wp-content/cache/background-css/example.org/blog/test/file2.css' => false,
'/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css' => true,
'/var/html/wp-content/cache/background-css/1/example.org/blog/test/file2.css' => false,
],
'content' => [
'/var/html/wp-content/cache/background-css/example.org/blog/test/file.css' => 'content'
'/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css' => 'content'
]
],
'expected' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'config' => [
'root' => '/var/html/wp-content/cache',
],
'expected' => '/var/html/wp-content/cache/background-css/'
'expected' => '/var/html/wp-content/cache/background-css/1/'
],

];
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
'expected' => [
'url' => 'http://example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => true
]
],
Expand All @@ -30,7 +30,7 @@
],
'expected' => [
'url' => 'http://example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => false
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'root' => '/var/html/wp-content/cache'
],
'expected' => [
'path' => '/var/html/wp-content/cache/background-css/',
'path' => '/var/html/wp-content/cache/background-css/1/',
'output' => false
]
],
Expand All @@ -19,7 +19,7 @@
'root' => '/var/html/wp-content/cache'
],
'expected' => [
'path' => '/var/html/wp-content/cache/background-css/',
'path' => '/var/html/wp-content/cache/background-css/1/',
'output' => true
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'expected' => [
'content' => 'content',
'url' => 'http://example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => true,
]
],
Expand All @@ -38,7 +38,7 @@
'expected' => [
'content' => 'content',
'url' => 'http://example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/example.org/blog/test/file.css',
'path' => '/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css',
'output' => false,
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
'home_url' => 'http://example.org',
'root' => '/var/html/wp-content/cache',
'saved' => [
'/var/html/wp-content/cache/background-css/example.org/blog/test/file.css' => [
'/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css' => [
'content' => 'content',
'output' => true,
],
'/var/html/wp-content/cache/background-css/example.org/blog/test/file2.css' => [
'/var/html/wp-content/cache/background-css/1/example.org/blog/test/file2.css' => [
'content' => 'content2',
'output' => true,
],
Expand Down Expand Up @@ -56,11 +56,11 @@
'home_url' => 'http://example.org',
'root' => '/var/html/wp-content/cache',
'saved' => [
'/var/html/wp-content/cache/background-css/example.org/blog/test/file.css' => [
'/var/html/wp-content/cache/background-css/1/example.org/blog/test/file.css' => [
'content' => 'content',
'output' => true,
],
'/var/html/wp-content/cache/background-css/example.org/blog/test/file2.css' => [
'/var/html/wp-content/cache/background-css/1/example.org/blog/test/file2.css' => [
'content' => 'content2',
'output' => false,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function set_up() {
*/
public function testShouldReturnAsExpected( $config, $expected ) {
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']);
$this->configureDirDelete($config, $expected);
$this->assertSame($expected['output'], $this->filesystemcache->clear());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function set_up() {
*/
public function testShouldReturnAsExpected( $config, $expected ) {
Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\when('get_current_blog_id')->justReturn( 1 );
Functions\expect('get_rocket_parse_url')->with($config['key'])->andReturn($config['parsed_url']);
Functions\when('home_url')->justReturn($config['home_url']);
$this->filesystem->shouldReceive('exists')->with($expected['path'])->andReturn($config['exists']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function set_up() {
*/
public function testShouldReturnAsExpected( $config, $expected ) {
Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\when('get_current_blog_id')->justReturn( 1 );
Functions\when('home_url')->justReturn($config['home_url']);
Functions\when('get_rocket_parse_url')->alias(function ($url) use ($config) {
if(! key_exists($url, $config['parsed_url'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function testShouldReturnAsExpected( $config, $expected )
});

Functions\when('home_url')->justReturn($config['home_url']);
Functions\when('get_current_blog_id')->justReturn( 1 );

Functions\when('rocket_get_constant')->alias(function ($name, $default = false) use ($config) {
if('WP_CONTENT_URL' === $name) {
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/inc/Engine/Common/Cache/FilesystemCache/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function testShouldReturnAsExpected( $config, $expected ) {
Functions\expect('get_rocket_parse_url')->with($expected['url'])->andReturn($config['parsed_url']);
Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\when('home_url')->justReturn($config['home_url']);
Functions\when('get_current_blog_id')->justReturn( 1 );

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function testShouldReturnAsExpected( $config, $expected ) {
return $config['parsed_url'][$url];
});
Functions\when('home_url')->justReturn($config['home_url']);
Functions\when('get_current_blog_id')->justReturn( 1 );

Functions\when('rocket_get_constant')->justReturn($config['root']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function set_up() {
public function testShouldReturnAsExpected( $config, $expected )
{
Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\when('get_current_blog_id')->justReturn( 1 );
$this->assertSame($expected, $this->filesystemcache->get_root_path());
}
}
1 change: 1 addition & 0 deletions tests/Unit/inc/Engine/Common/Cache/FilesystemCache/has.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function testShouldReturnAsExpected( $config, $expected ) {
Functions\expect('get_rocket_parse_url')->with($expected['url'])->andReturn($config['parsed_url']);
Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\when('home_url')->justReturn($config['home_url']);
Functions\when('get_current_blog_id')->justReturn( 1 );

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function set_up() {
*/
public function testShouldReturnAsExpected( $config, $expected ) {
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']) {
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/inc/Engine/Common/Cache/FilesystemCache/set.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function testShouldReturnAsExpected( $config, $expected ) {
Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\expect('rocket_mkdir_p')->with( dirname($expected['path']), $this->filesystem );
Functions\when('home_url')->justReturn($config['home_url']);
Functions\when('get_current_blog_id')->justReturn( 1 );

$this->filesystem->shouldReceive('put_contents')->with($expected['path'], $expected['content'], $config['rights'])->andReturn($config['saved']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function testShouldReturnAsExpected( $config, $expected ) {
Functions\when('rocket_mkdir_p')->justReturn();

Functions\when('rocket_get_constant')->justReturn($config['root']);
Functions\when('get_current_blog_id')->justReturn( 1 );

foreach ($config['saved'] as $path => $saved) {
$this->filesystem->shouldReceive('put_contents')->with($path, $saved['content'], $config['rights'])->andReturn($saved['output']);
Expand Down

0 comments on commit fefa3b0

Please sign in to comment.