File tree Expand file tree Collapse file tree 5 files changed +27
-11
lines changed
lib/internal/Magento/Framework/App
Test/Unit/Cache/Tag/Strategy Expand file tree Collapse file tree 5 files changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,6 @@ public function execute(\Magento\Framework\Event\Observer $observer)
73
73
*/
74
74
private function getTagResolver ()
75
75
{
76
- return ObjectManager::getInstance ()->get (' \Magento\Framework\App\Cache\Tag\Resolver ' );
76
+ return ObjectManager::getInstance ()->get (\Magento \Framework \App \Cache \Tag \Resolver::class );
77
77
}
78
78
}
Original file line number Diff line number Diff line change @@ -74,10 +74,10 @@ private function getCache()
74
74
75
75
/**
76
76
* @deprecated
77
- * @return \Magento\PageCache\Model \Cache\Tag\Resolver
77
+ * @return \Magento\Framework\App \Cache\Tag\Resolver
78
78
*/
79
79
private function getTagResolver ()
80
80
{
81
- return ObjectManager::getInstance ()->get (' \Magento\PageCache\Model \Cache\Tag\Resolver ' );
81
+ return ObjectManager::getInstance ()->get (\Magento \Framework \ App \Cache \Tag \Resolver::class );
82
82
}
83
83
}
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ class Dummy implements StrategyInterface
17
17
*/
18
18
public function getTags ($ object )
19
19
{
20
+ if (!is_object ($ object )) {
21
+ throw new \InvalidArgumentException ('Provided argument is not an object ' );
22
+ }
23
+
20
24
return [];
21
25
}
22
26
}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function __construct(
48
48
*
49
49
* @param object $object
50
50
* @throws \InvalidArgumentException
51
- * @return \Magento\Framework\App\Cache\Tag\StrategyInterface|null
51
+ * @return \Magento\Framework\App\Cache\Tag\StrategyInterface
52
52
*/
53
53
public function getStrategy ($ object )
54
54
{
@@ -62,7 +62,8 @@ class_parents($object),
62
62
class_implements ($ object )
63
63
);
64
64
65
- if ($ result = array_intersect (array_keys ($ this ->customStrategies ), $ classHierarchy )) {
65
+ $ result = array_intersect (array_keys ($ this ->customStrategies ), $ classHierarchy );
66
+ if ($ result ) {
66
67
return $ this ->customStrategies [array_shift ($ result )];
67
68
}
68
69
Original file line number Diff line number Diff line change 10
10
11
11
class DummyTest extends \PHPUnit_Framework_TestCase
12
12
{
13
- public function testGetTags ()
13
+
14
+ private $ model ;
15
+
16
+ protected function setUp ()
14
17
{
15
- $ model = new Dummy ();
16
- $ emptyArray = [];
18
+ $ this -> model = new Dummy ();
19
+ }
17
20
18
- $ this ->assertEquals ($ emptyArray , $ model ->getTags ('scalar ' ));
21
+ public function testGetTagsWithScalar ()
22
+ {
23
+ $ this ->setExpectedException (\InvalidArgumentException::class, 'Provided argument is not an object ' );
24
+ $ this ->model ->getTags ('scalar ' );
25
+ }
26
+
27
+ public function testGetTagsWithObject ()
28
+ {
29
+ $ emptyArray = [];
19
30
20
- $ this ->assertEquals ($ emptyArray , $ model ->getTags (new \StdClass ));
31
+ $ this ->assertEquals ($ emptyArray , $ this -> model ->getTags (new \StdClass ));
21
32
22
33
$ identityInterface = $ this ->getMockForAbstractClass (\Magento \Framework \DataObject \IdentityInterface::class);
23
- $ this ->assertEquals ($ emptyArray , $ model ->getTags ($ identityInterface ));
34
+ $ this ->assertEquals ($ emptyArray , $ this -> model ->getTags ($ identityInterface ));
24
35
}
25
36
}
You can’t perform that action at this time.
0 commit comments