From 5d1fb238c86b85bed6df1151944430ff239d17e6 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Thu, 29 Aug 2024 13:00:33 +0100 Subject: [PATCH] Modify unit test --- .../Admin/Controller/truncateOnUpdate.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/Unit/inc/Engine/Common/PerformanceHints/Admin/Controller/truncateOnUpdate.php b/tests/Unit/inc/Engine/Common/PerformanceHints/Admin/Controller/truncateOnUpdate.php index 640353397a..265d38f404 100644 --- a/tests/Unit/inc/Engine/Common/PerformanceHints/Admin/Controller/truncateOnUpdate.php +++ b/tests/Unit/inc/Engine/Common/PerformanceHints/Admin/Controller/truncateOnUpdate.php @@ -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; @@ -15,10 +16,11 @@ * * @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(); @@ -26,8 +28,10 @@ protected function setUp(): void { $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, @@ -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'] );