15
15
use Magento \Framework \App \CacheInterface ;
16
16
use Magento \Framework \Serialize \SerializerInterface ;
17
17
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
18
+ use Magento \Store \Api \Data \StoreInterface ;
19
+ use Magento \Store \Model \StoreManagerInterface ;
18
20
21
+ /**
22
+ * AttributeMetadataCache Test
23
+ *
24
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
25
+ */
19
26
class AttributeMetadataCacheTest extends \PHPUnit \Framework \TestCase
20
27
{
21
28
/**
@@ -43,20 +50,35 @@ class AttributeMetadataCacheTest extends \PHPUnit\Framework\TestCase
43
50
*/
44
51
private $ attributeMetadataCache ;
45
52
53
+ /**
54
+ * @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
55
+ */
56
+ private $ storeMock ;
57
+
58
+ /**
59
+ * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
60
+ */
61
+ private $ storeManagerMock ;
62
+
46
63
protected function setUp ()
47
64
{
48
65
$ objectManager = new ObjectManager ($ this );
49
66
$ this ->cacheMock = $ this ->createMock (CacheInterface::class);
50
67
$ this ->stateMock = $ this ->createMock (StateInterface::class);
51
68
$ this ->serializerMock = $ this ->createMock (SerializerInterface::class);
52
69
$ this ->attributeMetadataHydratorMock = $ this ->createMock (AttributeMetadataHydrator::class);
70
+ $ this ->storeMock = $ this ->createMock (StoreInterface::class);
71
+ $ this ->storeManagerMock = $ this ->createMock (StoreManagerInterface::class);
72
+ $ this ->storeManagerMock ->method ('getStore ' )->willReturn ($ this ->storeMock );
73
+ $ this ->storeMock ->method ('getId ' )->willReturn (1 );
53
74
$ this ->attributeMetadataCache = $ objectManager ->getObject (
54
75
AttributeMetadataCache::class,
55
76
[
56
77
'cache ' => $ this ->cacheMock ,
57
78
'state ' => $ this ->stateMock ,
58
79
'serializer ' => $ this ->serializerMock ,
59
- 'attributeMetadataHydrator ' => $ this ->attributeMetadataHydratorMock
80
+ 'attributeMetadataHydrator ' => $ this ->attributeMetadataHydratorMock ,
81
+ 'storeManager ' => $ this ->storeManagerMock
60
82
]
61
83
);
62
84
}
@@ -80,7 +102,8 @@ public function testLoadNoCache()
80
102
{
81
103
$ entityType = 'EntityType ' ;
82
104
$ suffix = 'none ' ;
83
- $ cacheKey = AttributeMetadataCache::ATTRIBUTE_METADATA_CACHE_PREFIX . $ entityType . $ suffix ;
105
+ $ storeId = 1 ;
106
+ $ cacheKey = AttributeMetadataCache::ATTRIBUTE_METADATA_CACHE_PREFIX . $ entityType . $ suffix . $ storeId ;
84
107
$ this ->stateMock ->expects ($ this ->once ())
85
108
->method ('isEnabled ' )
86
109
->with (Type::TYPE_IDENTIFIER )
@@ -96,7 +119,8 @@ public function testLoad()
96
119
{
97
120
$ entityType = 'EntityType ' ;
98
121
$ suffix = 'none ' ;
99
- $ cacheKey = AttributeMetadataCache::ATTRIBUTE_METADATA_CACHE_PREFIX . $ entityType . $ suffix ;
122
+ $ storeId = 1 ;
123
+ $ cacheKey = AttributeMetadataCache::ATTRIBUTE_METADATA_CACHE_PREFIX . $ entityType . $ suffix . $ storeId ;
100
124
$ serializedString = 'serialized string ' ;
101
125
$ attributeMetadataOneData = [
102
126
'attribute_code ' => 'attribute_code ' ,
@@ -156,7 +180,8 @@ public function testSave()
156
180
{
157
181
$ entityType = 'EntityType ' ;
158
182
$ suffix = 'none ' ;
159
- $ cacheKey = AttributeMetadataCache::ATTRIBUTE_METADATA_CACHE_PREFIX . $ entityType . $ suffix ;
183
+ $ storeId = 1 ;
184
+ $ cacheKey = AttributeMetadataCache::ATTRIBUTE_METADATA_CACHE_PREFIX . $ entityType . $ suffix . $ storeId ;
160
185
$ serializedString = 'serialized string ' ;
161
186
$ attributeMetadataOneData = [
162
187
'attribute_code ' => 'attribute_code ' ,
0 commit comments