Skip to content

Commit 94ad2e8

Browse files
author
Oleksii Kolesnyk
committed
MTA-2480: Extend Use Advanced Search
- Add constraint that checks cache invalidated and refreshable
1 parent 44d25ce commit 94ad2e8

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Block\Cache;
8+
9+
use Magento\Backend\Test\Block\Widget\Grid as ParentGrid;
10+
11+
/**
12+
* Backend Cache Management grid.
13+
*/
14+
class Grid extends ParentGrid
15+
{
16+
/**
17+
* Search for item and select it
18+
*
19+
* @param array $filter
20+
* @throws \Exception
21+
*/
22+
public function searchAndSelect(array $filter)
23+
{
24+
$selectItem = $this->getRow($filter, false)->find($this->selectItem);
25+
if ($selectItem->isVisible()) {
26+
$selectItem->click();
27+
} else {
28+
throw new \Exception('Searched item was not found.');
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Backend\Test\Page\Adminhtml\AdminCache;
11+
12+
/**
13+
* Assert Cache is Invalidated and Refreshable.
14+
*/
15+
class AssertCacheIsRefreshableAndInvalidated extends AbstractConstraint
16+
{
17+
/**
18+
* Success message of refreshed cache.
19+
*/
20+
const SUCCESS_MESSAGE = '%d cache type(s) refreshed.';
21+
22+
/**
23+
* Assert Cache is Invalidated and Refreshable.
24+
*
25+
* @param AdminCache $adminCache
26+
* @param array $cacheTags
27+
* @return void
28+
*/
29+
public function processAssert(AdminCache $adminCache, $cacheTags)
30+
{
31+
$items = [];
32+
foreach ($cacheTags as $cacheTag) {
33+
$items[] = [
34+
'tags' => $cacheTag,
35+
'status' => 'Invalidated'
36+
];
37+
}
38+
39+
$adminCache->open();
40+
$adminCache->getGridBlock()->massaction($items, 'Refresh');
41+
42+
\PHPUnit_Framework_Assert::assertEquals(
43+
sprintf(self::SUCCESS_MESSAGE, count($items)),
44+
$adminCache->getMessagesBlock()->getSuccessMessages(),
45+
'Cache is Invalid and refreshable.'
46+
);
47+
}
48+
49+
/**
50+
* Returns a string representation of the object.
51+
*
52+
* @return string
53+
*/
54+
public function toString()
55+
{
56+
return 'Cache is not Invalid or not refreshable.';
57+
}
58+
}

dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages .messages" strategy="css selector"/>
1111
<block name="actionsBlock" class="Magento\Backend\Test\Block\Cache" locator="div.page-actions" strategy="css selector"/>
1212
<block name="additionalBlock" class="Magento\Backend\Test\Block\Cache\Additional" locator="div.additional-cache-management" strategy="css selector"/>
13+
<block name="gridBlock" class="Magento\Backend\Test\Block\Cache\Grid" locator="div#cache_grid" strategy="css selector"/>
1314
</page>
1415
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
<data name="productAttributeOriginal/dataset" xsi:type="string">tax_class_id</data>
5656
<data name="attribute/data/is_searchable" xsi:type="string">Yes</data>
5757
<data name="attribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data>
58+
<data name="cacheTags" xsi:type="array">
59+
<item name="0" xsi:type="string">FPC</item>
60+
</data>
61+
<constraint name="Magento\Backend\Test\Constraint\AssertCacheIsRefreshableAndInvalidated" />
5862
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductByAttribute" />
5963
</variation>
6064
</testCase>

0 commit comments

Comments
 (0)