83 $this->productMock->expects($this->any())
85 ->willReturn(self::PRODUCT_ID);
87 $this->websiteMock = $this->getMockBuilder(\
Magento\
Store\Model\Website::class)
88 ->setMethods([
'getId',
'getName'])
89 ->disableOriginalConstructor()
91 $this->secondWebsiteMock = $this->getMockBuilder(\
Magento\
Store\Model\Website::class)
92 ->setMethods([
'getId',
'getName'])
93 ->disableOriginalConstructor()
95 $this->websiteRepositoryMock = $this->getMockBuilder(\
Magento\
Store\Api\WebsiteRepositoryInterface::class)
96 ->setMethods([
'getList'])
97 ->getMockForAbstractClass();
98 $this->websiteRepositoryMock->expects($this->any())
99 ->method(
'getDefault')
100 ->willReturn($this->websiteMock);
101 $this->groupRepositoryMock = $this->getMockBuilder(\
Magento\
Store\Api\GroupRepositoryInterface::class)
102 ->setMethods([
'getList'])
103 ->getMockForAbstractClass();
104 $this->storeRepositoryMock = $this->getMockBuilder(\
Magento\
Store\Api\StoreRepositoryInterface::class)
105 ->setMethods([
'getList'])
106 ->getMockForAbstractClass();
107 $this->productMock = $this->getMockBuilder(\
Magento\Catalog\Api\Data\ProductInterface::class)
108 ->setMethods([
'getId'])
109 ->getMockForAbstractClass();
110 $this->locatorMock->expects($this->any())
111 ->method(
'getWebsiteIds')
112 ->willReturn($this->assignedWebsites);
113 $this->storeManagerMock = $this->getMockBuilder(\
Magento\
Store\Model\StoreManagerInterface::class)
114 ->setMethods([
'isSingleStoreMode',
'getWesites'])
115 ->getMockForAbstractClass();
116 $this->storeManagerMock->method(
'getWebsites')
117 ->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
118 $this->storeManagerMock->expects($this->any())
119 ->method(
'isSingleStoreMode')
122 ->setMethods([
'getId',
'getName',
'getWebsiteId'])
123 ->disableOriginalConstructor()
125 $this->groupMock->expects($this->any())
126 ->method(
'getWebsiteId')
127 ->willReturn(self::WEBSITE_ID);
128 $this->groupMock->expects($this->any())
130 ->willReturn(self::GROUP_ID);
131 $this->groupRepositoryMock->expects($this->any())
133 ->willReturn([$this->groupMock]);
134 $this->storeViewMock = $this->getMockBuilder(\
Magento\
Store\Model\Store::class)
135 ->setMethods([
'getName',
'getId',
'getStoreGroupId'])
136 ->disableOriginalConstructor()
138 $this->storeViewMock->expects($this->any())
140 ->willReturn(self::STORE_VIEW_NAME);
141 $this->storeViewMock->expects($this->any())
142 ->method(
'getStoreGroupId')
143 ->willReturn(self::GROUP_ID);
144 $this->storeViewMock->expects($this->any())
146 ->willReturn(self::STORE_VIEW_ID);
147 $this->storeRepositoryMock->expects($this->any())
149 ->willReturn([$this->storeViewMock]);
150 $this->secondWebsiteMock->expects($this->any())
152 ->willReturn($this->assignedWebsites[0]);
153 $this->websiteMock->expects($this->any())
155 ->willReturn(self::WEBSITE_ID);
163 return $this->objectManager->getObject(
166 'locator' => $this->locatorMock,
167 'storeManager' => $this->storeManagerMock,
168 'websiteRepository' => $this->websiteRepositoryMock,
169 'groupRepository' => $this->groupRepositoryMock,
170 'storeRepository' => $this->storeRepositoryMock,
180 $meta = $this->
getModel()->modifyMeta([]);
181 $this->assertTrue(isset($meta[
'websites']));
182 $this->assertTrue(isset($meta[
'websites'][
'children'][self::SECOND_WEBSITE_ID]));
183 $this->assertTrue(isset($meta[
'websites'][
'children'][self::WEBSITE_ID]));
184 $this->assertTrue(isset($meta[
'websites'][
'children'][
'copy_to_stores.' . self::WEBSITE_ID]));
193 self::PRODUCT_ID => [
195 'copy_to_stores' => [
196 self::WEBSITE_ID => [