Skip to content

Commit c160fc7

Browse files
committed
MAGETWO-91497: Product websites are not honored
1 parent d9f6941 commit c160fc7

File tree

2 files changed

+2
-38
lines changed

2 files changed

+2
-38
lines changed

app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ public function testGetBySkuFromCacheInitializedInGetById()
550550

551551
public function testSaveExisting()
552552
{
553-
$this->storeManagerMock->expects($this->any())->method('getWebsites')->willReturn([1 => 'default']);
554553
$this->resourceModelMock->expects($this->any())->method('getIdBySku')->will($this->returnValue(100));
555554
$this->productFactoryMock->expects($this->any())
556555
->method('create')
@@ -563,7 +562,6 @@ public function testSaveExisting()
563562
->expects($this->once())
564563
->method('toNestedArray')
565564
->will($this->returnValue($this->productData));
566-
$this->productMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
567565
$this->productMock->expects($this->atLeastOnce())->method('getSku')->willReturn($this->productData['sku']);
568566

569567
$this->assertEquals($this->productMock, $this->model->save($this->productMock));
@@ -585,7 +583,6 @@ public function testSaveNew()
585583
->expects($this->once())
586584
->method('toNestedArray')
587585
->will($this->returnValue($this->productData));
588-
$this->productMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
589586

590587
$this->assertEquals($this->productMock, $this->model->save($this->productMock));
591588
}
@@ -610,7 +607,6 @@ public function testSaveUnableToSaveException()
610607
->expects($this->once())
611608
->method('toNestedArray')
612609
->will($this->returnValue($this->productData));
613-
$this->productMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
614610

615611
$this->model->save($this->productMock);
616612
}
@@ -636,7 +632,6 @@ public function testSaveException()
636632
->expects($this->once())
637633
->method('toNestedArray')
638634
->will($this->returnValue($this->productData));
639-
$this->productMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
640635

641636
$this->model->save($this->productMock);
642637
}
@@ -660,7 +655,6 @@ public function testSaveInvalidProductException()
660655
->expects($this->once())
661656
->method('toNestedArray')
662657
->will($this->returnValue($this->productData));
663-
$this->productMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
664658

665659
$this->model->save($this->productMock);
666660
}
@@ -689,9 +683,6 @@ public function testSaveThrowsTemporaryStateExceptionIfDatabaseConnectionErrorOc
689683
->expects($this->once())
690684
->method('toNestedArray')
691685
->will($this->returnValue($this->productData));
692-
$this->productMock->expects($this->once())
693-
->method('getWebsiteIds')
694-
->willReturn([]);
695686

696687
$this->model->save($this->productMock);
697688
}
@@ -839,7 +830,6 @@ public function testSaveExistingWithOptions(array $newOptions, array $existingOp
839830
->method('toNestedArray')
840831
->will($this->returnValue($this->productData));
841832

842-
$this->initializedProductMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
843833
$this->initializedProductMock->expects($this->atLeastOnce())
844834
->method('getSku')->willReturn($this->productData['sku']);
845835
$this->productMock->expects($this->atLeastOnce())->method('getSku')->willReturn($this->productData['sku']);
@@ -1075,7 +1065,6 @@ public function testSaveWithLinks(array $newLinks, array $existingLinks, array $
10751065
$outputLinks[] = $outputLink;
10761066
}
10771067
}
1078-
$this->initializedProductMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
10791068

10801069
if (!empty($outputLinks)) {
10811070
$this->initializedProductMock->expects($this->once())
@@ -1256,7 +1245,6 @@ public function testSaveExistingWithNewMediaGalleryEntries()
12561245
'media_type' => 'media_type',
12571246
]
12581247
);
1259-
$this->initializedProductMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
12601248
$this->initializedProductMock->expects($this->atLeastOnce())
12611249
->method('getSku')->willReturn($this->productData['sku']);
12621250
$this->productMock->expects($this->atLeastOnce())->method('getSku')->willReturn($this->productData['sku']);
@@ -1297,7 +1285,6 @@ public function testSaveWithDifferentWebsites()
12971285
2 => ['second'],
12981286
3 => ['third']
12991287
]);
1300-
$this->productMock->expects($this->once())->method('getWebsiteIds')->willReturn([1,2,3]);
13011288
$this->productMock->expects($this->once())->method('setWebsiteIds')->willReturn([2,3]);
13021289

13031290
$this->assertEquals($this->productMock, $this->model->save($this->productMock));
@@ -1368,7 +1355,6 @@ public function testSaveExistingWithMediaGalleryEntries()
13681355
$this->mediaGalleryProcessor->expects($this->once())
13691356
->method('setMediaAttribute')
13701357
->with($this->initializedProductMock, ['image', 'small_image'], 'filename1');
1371-
$this->initializedProductMock->expects($this->once())->method('getWebsiteIds')->willReturn([]);
13721358
$this->initializedProductMock->expects($this->atLeastOnce())
13731359
->method('getSku')->willReturn($this->productData['sku']);
13741360
$this->productMock->expects($this->atLeastOnce())->method('getSku')->willReturn($this->productData['sku']);

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ public function productCreationProvider()
147147
private function loadWebsiteByCode($websiteCode)
148148
{
149149
$websiteRepository = Bootstrap::getObjectManager()->get(WebsiteRepository::class);
150-
try{
150+
try {
151151
$website = $websiteRepository->get($websiteCode);
152-
} catch (NoSuchEntityException $e){
152+
} catch (NoSuchEntityException $e) {
153153
$this->fail("Couldn`t load website: {$websiteCode}");
154154
}
155155

@@ -186,8 +186,6 @@ public function testUpdateWithDeleteWebsites()
186186
public function testDeleteAllWebsiteAssociations()
187187
{
188188
$productBuilder[ProductInterface::SKU] = 'unique-simple-azaza';
189-
/** @var Website $website */
190-
$website = $this->loadWebsiteByCode('second_website');
191189

192190
$websitesData = [
193191
'website_ids' => []
@@ -280,26 +278,6 @@ public function testUpdateWithNonDefaultStoreWebsite()
280278
);
281279
}
282280

283-
/**
284-
* Update product to be associated with no websites
285-
*
286-
* @magentoApiDataFixture Magento/Catalog/_files/product_with_two_websites.php
287-
*/
288-
public function testUpdateWithNoWebsite()
289-
{
290-
$productBuilder[ProductInterface::SKU] = 'unique-simple-azaza';
291-
292-
$websitesData = [
293-
'website_ids' => []
294-
];
295-
$productBuilder[ProductInterface::EXTENSION_ATTRIBUTES_KEY] = $websitesData;
296-
$response = $this->updateProduct($productBuilder);
297-
$this->assertEquals(
298-
$websitesData["website_ids"],
299-
$response[ProductInterface::EXTENSION_ATTRIBUTES_KEY]["website_ids"]
300-
);
301-
}
302-
303281
/**
304282
* Update product without specifying websites
305283
*

0 commit comments

Comments
 (0)