@@ -23,11 +23,15 @@ class FlushCacheByTagsTest extends \PHPUnit_Framework_TestCase
23
23
/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\PageCache\Model\Cache\Type */
24
24
private $ fullPageCacheMock ;
25
25
26
+ /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Cache\Tag\Resolver */
27
+ private $ tagResolver ;
28
+
26
29
/**
27
30
* Set up all mocks and data for test
28
31
*/
29
32
protected function setUp ()
30
33
{
34
+ $ helper = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
31
35
$ this ->_configMock = $ this ->getMock (
32
36
\Magento \PageCache \Model \Config::class,
33
37
['getType ' , 'isEnabled ' ],
@@ -42,6 +46,11 @@ protected function setUp()
42
46
$ this ->_configMock ,
43
47
$ this ->_cacheMock
44
48
);
49
+
50
+ $ this ->tagResolver = $ this ->getMock (\Magento \Framework \App \Cache \Tag \Resolver::class, [], [], '' , false );
51
+
52
+
53
+ $ helper ->setBackwardCompatibleProperty ($ this ->_model , 'tagResolver ' , $ this ->tagResolver );
45
54
$ reflection = new \ReflectionClass (\Magento \PageCache \Observer \FlushCacheByTags::class);
46
55
$ reflectionProperty = $ reflection ->getProperty ('fullPageCache ' );
47
56
$ reflectionProperty ->setAccessible (true );
@@ -70,7 +79,7 @@ public function testExecute($cacheState)
70
79
$ this ->_configMock ->expects ($ this ->once ())
71
80
->method ('getType ' )
72
81
->willReturn (\Magento \PageCache \Model \Config::BUILT_IN );
73
- $ observedObject -> expects ($ this ->once ())->method ('getIdentities ' )->will ($ this ->returnValue ($ tags ));
82
+ $ this -> tagResolver -> expects ($ this ->once ())->method ('getTags ' )->will ($ this ->returnValue ($ tags ));
74
83
75
84
$ this ->fullPageCacheMock ->expects ($ this ->once ())
76
85
->method ('clean ' )
@@ -106,7 +115,7 @@ public function testExecuteWithEmptyTags()
106
115
)->will (
107
116
$ this ->returnValue (\Magento \PageCache \Model \Config::BUILT_IN )
108
117
);
109
- $ observedObject -> expects ($ this ->once ())->method ('getIdentities ' )->will ($ this ->returnValue ($ tags ));
118
+ $ this -> tagResolver -> expects ($ this ->once ())->method ('getTags ' )->will ($ this ->returnValue ($ tags ));
110
119
111
120
$ this ->fullPageCacheMock ->expects ($ this ->never ())->method ('clean ' );
112
121
0 commit comments