Skip to content

Commit bbb48ae

Browse files
committed
MAGE-1378 Update unit tests
1 parent 979f992 commit bbb48ae

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Test/Unit/Plugin/RenderingCacheContextPluginTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,34 @@
33
namespace Algolia\AlgoliaSearch\Test\Unit\Plugin;
44

55
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
6+
use Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper;
67
use Algolia\AlgoliaSearch\Plugin\RenderingCacheContextPlugin;
78
use Magento\Framework\App\Http\Context as HttpContext;
89
use Magento\Framework\App\Request\Http;
910
use Magento\Store\Api\Data\StoreInterface;
1011
use Magento\Store\Model\StoreManagerInterface;
1112
use Magento\UrlRewrite\Model\UrlFinderInterface;
1213
use PHPUnit\Framework\TestCase;
13-
1414
class RenderingCacheContextPluginTest extends TestCase
1515
{
1616
protected ?RenderingCacheContextPlugin $plugin;
1717
protected ?ConfigHelper $configHelper;
18+
19+
protected ?InstantSearchHelper $instantSearchHelper;
1820
protected ?StoreManagerInterface $storeManager;
1921
protected ?Http $request;
2022
protected ?UrlFinderInterface $urlFinder;
21-
2223
protected function setUp(): void
2324
{
2425
$this->configHelper = $this->createMock(ConfigHelper::class);
26+
$this->instantSearchHelper = $this->createMock(InstantSearchHelper::class);
2527
$this->storeManager = $this->createMock(StoreManagerInterface::class);
2628
$this->request = $this->createMock(Http::class);
2729
$this->urlFinder = $this->createMock(UrlFinderInterface::class);
2830

2931
$this->plugin = new RenderingCacheContextPluginTestable(
3032
$this->configHelper,
33+
$this->instantSearchHelper,
3134
$this->storeManager,
3235
$this->request,
3336
$this->urlFinder
@@ -47,7 +50,7 @@ public function testAfterGetDataAddsRenderingContextNoBackendRender(): void
4750
$this->storeManager->method('getStore')->willReturn($this->getStoreMock());
4851

4952
$this->request->method('getControllerName')->willReturn('category');
50-
$this->configHelper->method('replaceCategories')->willReturn(true);
53+
$this->instantSearchHelper->method('shouldReplaceCategories')->willReturn(true);
5154

5255
$result = $this->plugin->afterGetData(
5356
$this->createMock(HttpContext::class),
@@ -66,7 +69,7 @@ public function testAfterGetDataAddsRenderingContextWithBackendRender(): void
6669
$this->storeManager->method('getStore')->willReturn($this->getStoreMock());
6770

6871
$this->request->method('getControllerName')->willReturn('category');
69-
$this->configHelper->method('replaceCategories')->willReturn(true);
72+
$this->instantSearchHelper->method('shouldReplaceCategories')->willReturn(true);
7073

7174
$result = $this->plugin->afterGetData(
7275
$this->createMock(HttpContext::class),
@@ -86,7 +89,7 @@ public function testAfterGetDataDoesNotModifyDataIfNotApplicable(): void
8689

8790
$this->request->method('getControllerName')->willReturn('product');
8891
$this->request->method('getRequestUri')->willReturn('some-product.html');
89-
$this->configHelper->method('replaceCategories')->willReturn(false);
92+
$this->instantSearchHelper->method('shouldReplaceCategories')->willReturn(false);
9093

9194
$data = ['existing_key' => 'existing_value'];
9295
$result = $this->plugin->afterGetData($subject, $data);
@@ -121,7 +124,7 @@ public function testShouldApplyCacheContext(): void
121124
$this->storeManager->method('getStore')->willReturn($this->getStoreMock());
122125

123126
$this->request->method('getControllerName')->willReturn('category');
124-
$this->configHelper->method('replaceCategories')->willReturn(true);
127+
$this->instantSearchHelper->method('shouldReplaceCategories')->willReturn(true);
125128

126129
$this->assertTrue($this->plugin->shouldApplyCacheContext());
127130
}

0 commit comments

Comments
 (0)