Skip to content

Commit 8d5f075

Browse files
authored
Updated testIsCacheable
1 parent 1c8b19a commit 8d5f075

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

app/code/Magento/Search/Test/Unit/Model/PopularSearchTermsTest.php

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,47 +49,28 @@ protected function setUp()
4949
/**
5050
* Test isCacheableDataProvider method
5151
*
52-
* @dataProvider isCacheableDataProvider
53-
*
5452
* @param string $term
5553
* @param array $terms
5654
* @param $expected $terms
5755
*
5856
* @return void
5957
*/
60-
public function testIsCacheable($term, $terms, $expected)
58+
public function testIsCacheable()
6159
{
62-
$storeId = 7;
63-
$pageSize = 25;
64-
60+
$term = 'test1';
61+
$storeId = 1;
62+
$pageSize = 35;
63+
6564
$this->scopeConfigMock->expects($this->once())->method('getValue')
6665
->with(
6766
PopularSearchTerms::XML_PATH_MAX_COUNT_CACHEABLE_SEARCH_TERMS,
6867
ScopeInterface::SCOPE_STORE,
6968
$storeId
7069
)->willReturn($pageSize);
71-
$this->queryCollectionMock->expects($this->once())->method('setPopularQueryFilter')->with($storeId)
72-
->willReturnSelf();
73-
$this->queryCollectionMock->expects($this->once())->method('setPageSize')->with($pageSize)
74-
->willReturnSelf();
75-
$this->queryCollectionMock->expects($this->once())->method('load')->willReturnSelf();
76-
$this->queryCollectionMock->expects($this->once())->method('getColumnValues')->with('query_text')
77-
->willReturn($terms);
78-
79-
$actual = $this->popularSearchTerms->isCacheable($term, $storeId);
80-
self::assertEquals($expected, $actual);
81-
}
70+
$this->queryCollectionMock->expects($this->once())->method('isTopSearchResult')->with($term, $storeId, $pageSize)
71+
->willReturn(true, false);
8272

83-
/**
84-
* @return array
85-
*/
86-
public function isCacheableDataProvider()
87-
{
88-
return [
89-
['test01', [], false],
90-
['test02', ['test01', 'test02'], true],
91-
['test03', ['test01', 'test02'], false],
92-
['test04', ['test04'], true],
93-
];
73+
$this->assertTrue($this->popularSearchTerms->isCacheable($term, $storeId));
74+
$this->assertFalse($this->popularSearchTerms->isCacheable($term, $storeId));
9475
}
9576
}

0 commit comments

Comments
 (0)