|
12 | 12 | use Magento\Framework\Api\Data\ImageContentInterface;
|
13 | 13 | use Magento\Framework\Api\SortOrder;
|
14 | 14 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
| 15 | +use Magento\Store\Api\Data\StoreInterface; |
15 | 16 |
|
16 | 17 | /**
|
17 | 18 | * Tests \Magento\Catalog\Model\ProductRepositoryTest
|
@@ -1267,6 +1268,45 @@ public function testSaveExistingWithNewMediaGalleryEntries()
|
1267 | 1268 | $this->model->save($this->productMock);
|
1268 | 1269 | }
|
1269 | 1270 |
|
| 1271 | + public function testSaveWithDifferentWebsites() |
| 1272 | + { |
| 1273 | + $getWebsitesResultData = [ |
| 1274 | + 1 => ['first'], |
| 1275 | + 2 => ['second'], |
| 1276 | + 3 => ['third'] |
| 1277 | + ]; |
| 1278 | + $getWebsiteIdsResultData = [1,2,3]; |
| 1279 | + $setWebsiteIdsResultData = [2,3]; |
| 1280 | + $getIdBySkuResultData = 100; |
| 1281 | + $storeMock = $this->getMock(StoreInterface::class); |
| 1282 | + $this->resourceModelMock->expects($this->at(0))->method('getIdBySku')->will($this->returnValue(null)); |
| 1283 | + $this->resourceModelMock |
| 1284 | + ->expects($this->at(3)) |
| 1285 | + ->method('getIdBySku') |
| 1286 | + ->will($this->returnValue($getIdBySkuResultData)); |
| 1287 | + $this->productFactoryMock->expects($this->any()) |
| 1288 | + ->method('create') |
| 1289 | + ->will($this->returnValue($this->productMock)); |
| 1290 | + $this->initializationHelperMock->expects($this->never())->method('initialize'); |
| 1291 | + $this->resourceModelMock->expects($this->once())->method('validate')->with($this->productMock) |
| 1292 | + ->willReturn(true); |
| 1293 | + $this->resourceModelMock->expects($this->once())->method('save')->with($this->productMock)->willReturn(true); |
| 1294 | + $this->extensibleDataObjectConverterMock |
| 1295 | + ->expects($this->once()) |
| 1296 | + ->method('toNestedArray') |
| 1297 | + ->will($this->returnValue($this->productData)); |
| 1298 | + $this->storeManagerMock->expects($this->any()) |
| 1299 | + ->method('getStore') |
| 1300 | + ->willReturn($storeMock); |
| 1301 | + $this->storeManagerMock->expects($this->once()) |
| 1302 | + ->method('getWebsites') |
| 1303 | + ->willReturn($getWebsitesResultData); |
| 1304 | + $this->productMock->expects($this->once())->method('getWebsiteIds')->willReturn($getWebsiteIdsResultData); |
| 1305 | + $this->productMock->expects($this->once())->method('setWebsiteIds')->willReturn($setWebsiteIdsResultData); |
| 1306 | + |
| 1307 | + $this->assertEquals($this->productMock, $this->model->save($this->productMock)); |
| 1308 | + } |
| 1309 | + |
1270 | 1310 | public function testSaveExistingWithMediaGalleryEntries()
|
1271 | 1311 | {
|
1272 | 1312 | //update one entry, delete one entry
|
|
0 commit comments