Skip to content

Commit

Permalink
Modify unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Aug 29, 2024
1 parent 1bf9dcc commit 5d1fb23
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace WP_Rocket\tests\Unit\inc\Engine\Common\PerformanceHints\Admin\Controller;

use Mockery;
use WP_Rocket\Engine\Common\Context\ContextInterface;
use WP_Rocket\Tests\Unit\TestCase;
use WP_Rocket\Engine\Common\PerformanceHints\Admin\Controller;
use WP_Rocket\Engine\Media\AboveTheFold\Factory as ATFFactory;
Expand All @@ -15,19 +16,22 @@
*
* @group PerformanceHints
*/
class TestTruncateOnUpdate extends TestCase {
class Test_TruncateOnUpdate extends TestCase {
private $factories;
private $queries;
private $table;
private $context;

protected function setUp(): void {
parent::setUp();

$this->queries = $this->createMock(AboveTheFold::class);
$this->table = $this->createMock(ATFTable::class);
$atf_factory = $this->createMock(ATFFactory::class);
$this->context = $this->createMock(ContextInterface::class);
$atf_factory->method('queries')->willReturn($this->queries);
$atf_factory->method('table')->willReturn($this->table);
$atf_factory->method('get_context')->willReturn($this->context);

$this->factories = [
$atf_factory,
Expand All @@ -44,6 +48,10 @@ public function testShouldDoExpected( $config, $expected ) {
$this->queries->expects( $this->never() )
->method( 'get_not_completed_count' );
} else {
$this->context->expects( $this->once() )
->method('is_allowed')
->willReturn(true);

$this->queries->expects( $this->once() )
->method( 'get_not_completed_count' )
->willReturn( $config['not_completed'] );
Expand Down

0 comments on commit 5d1fb23

Please sign in to comment.