-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into enhancement/6879-meta-generator
- Loading branch information
Showing
16 changed files
with
175 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
tests/Fixtures/inc/Engine/Common/PerformanceHints/Database/deleteByUrl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
$result_one = (object) [ | ||
'id' => 1 | ||
]; | ||
|
||
$result_two = (object) [ | ||
'id' => 2 | ||
]; | ||
|
||
$empty_result_one = (object) [ | ||
]; | ||
|
||
return [ | ||
'notResultsShouldNotDelete' => [ | ||
'config' => [ | ||
'url' => 'http://example.com', | ||
'results' => [], | ||
'deleted_item' => 0 | ||
], | ||
'expected' => false, | ||
], | ||
'resultsWithEmptyObjectShouldReturnFalse' => [ | ||
'config' => [ | ||
'url' => 'http://example.com', | ||
'deleted_item' => 1, | ||
'results' => [ | ||
$empty_result_one, | ||
$result_two, | ||
], | ||
'delete_id_one' => true, | ||
'delete_id_two' => 2, | ||
'delete_return_one' => true, | ||
'delete_return_two' => true, | ||
], | ||
'expected' => true, | ||
], | ||
'resultsWithOneErrorShouldReturnFalse' => [ | ||
'config' => [ | ||
'url' => 'http://example.com', | ||
'deleted_item' => 2, | ||
'results' => [ | ||
$result_one, | ||
$result_two, | ||
], | ||
'delete_id_one' => 1, | ||
'delete_id_two' => 2, | ||
'delete_return_one' => true, | ||
'delete_return_two' => true, | ||
], | ||
'expected' => true, | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
tests/Unit/inc/Engine/Common/PerformanceHints/Database/deleteByUrl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Engine\Common\PerformanceHints\Database; | ||
|
||
use WP_Rocket\Tests\Unit\TestCase; | ||
use WP_Rocket\Engine\Common\PerformanceHints\Database\Queries\AbstractQueries; | ||
/** | ||
* Test class covering WP_Rocket\Engine\Common\PerformanceHints\Database\Queries\AbstractQueries::delete_by_url | ||
* | ||
* @group PerformanceHints | ||
*/ | ||
class Test_DeleteByUrl extends TestCase | ||
{ | ||
protected $query; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->query = $this->createPartialMock( AbstractQueries::class, [ 'table_exists', 'get_rows_by_url', 'delete_item' ] ); | ||
} | ||
|
||
/** | ||
* @dataProvider configTestData | ||
*/ | ||
public function testShouldReturnAsExpected($config, $expected) { | ||
$this->query->expects($this->once()) | ||
->method('table_exists') | ||
->willReturn(true); | ||
|
||
$this->query->expects(self::once())->method('get_rows_by_url')->with($config['url'])->willReturn($config['results']); | ||
$this->configureDelete($config, $expected); | ||
|
||
$this->assertSame($expected, $this->query->delete_by_url($config['url'])); | ||
} | ||
|
||
protected function configureDelete($config, $expected) { | ||
if(count($config['results']) === 0) { | ||
return; | ||
} | ||
if ( ! $expected ) { | ||
return; | ||
} | ||
|
||
$this->query->expects(self::exactly($config['deleted_item']))->method('delete_item') | ||
->withConsecutive([$config['delete_id_one']], [$config['delete_id_two']]) | ||
->willReturnOnConsecutiveCalls($config['delete_return_one'], $config['delete_return_two']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters