Skip to content

Commit f17148f

Browse files
committed
add simple unit test for #29890
1 parent 256cedd commit f17148f

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Magento\Framework\Indexer\Test\Unit;
10+
11+
use Magento\Framework\Indexer\CacheContext;
12+
use PHPUnit\Framework\TestCase;
13+
14+
class CacheContextTest extends TestCase
15+
{
16+
/**
17+
* @var Batch
18+
*/
19+
private $object;
20+
21+
protected function setUp(): void
22+
{
23+
$this->object = new CacheContext();
24+
}
25+
26+
/**
27+
* @param array $tagsData
28+
* @param array $expected
29+
* @dataProvider getTagsDataProvider
30+
*/
31+
public function testUniqueTags($tagsData, $expected)
32+
{
33+
foreach ($tagsData as $tagSet) {
34+
foreach ($tagSet as $cacheTag => $ids) {
35+
$this->object->registerEntities($cacheTag, $ids);
36+
}
37+
}
38+
39+
$this->assertEquals($this->object->getIdentities(), $expected);
40+
}
41+
42+
/**
43+
* @return array
44+
*/
45+
public function getTagsDataProvider()
46+
{
47+
return [
48+
'same entities and ids' => [
49+
[['cat_p' => [1]], ['cat_p' => [1]]],
50+
['cat_p_1']
51+
],
52+
'same entities with overlapping ids' => [
53+
[['cat_p' => [1, 2, 3]], ['cat_p' => [3]]],
54+
['cat_p_1', 'cat_p_2', 'cat_p_3']
55+
]
56+
];
57+
}
58+
}
59+

0 commit comments

Comments
 (0)