|
13 | 13 | use Magento\Framework\Api\ExtensibleDataInterface;
|
14 | 14 | use Magento\Framework\Api\ExtensionAttributesFactory;
|
15 | 15 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
|
| 16 | +use Magento\Store\Model\StoreManagerInterface; |
16 | 17 |
|
17 | 18 | /**
|
18 | 19 | * Product Test
|
@@ -207,6 +208,11 @@ class ProductTest extends \PHPUnit\Framework\TestCase
|
207 | 208 | */
|
208 | 209 | private $eavConfig;
|
209 | 210 |
|
| 211 | + /** |
| 212 | + * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject |
| 213 | + */ |
| 214 | + private $storeManager; |
| 215 | + |
210 | 216 | /**
|
211 | 217 | * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
212 | 218 | */
|
@@ -303,13 +309,13 @@ protected function setUp()
|
303 | 309 | ->disableOriginalConstructor()
|
304 | 310 | ->getMock();
|
305 | 311 |
|
306 |
| - $storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) |
| 312 | + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) |
307 | 313 | ->disableOriginalConstructor()
|
308 | 314 | ->getMockForAbstractClass();
|
309 |
| - $storeManager->expects($this->any()) |
| 315 | + $this->storeManager->expects($this->any()) |
310 | 316 | ->method('getStore')
|
311 | 317 | ->will($this->returnValue($this->store));
|
312 |
| - $storeManager->expects($this->any()) |
| 318 | + $this->storeManager->expects($this->any()) |
313 | 319 | ->method('getWebsite')
|
314 | 320 | ->will($this->returnValue($this->website));
|
315 | 321 | $this->indexerRegistryMock = $this->createPartialMock(
|
@@ -394,7 +400,7 @@ protected function setUp()
|
394 | 400 | 'extensionFactory' => $this->extensionAttributesFactory,
|
395 | 401 | 'productPriceIndexerProcessor' => $this->productPriceProcessor,
|
396 | 402 | 'catalogProductOptionFactory' => $optionFactory,
|
397 |
| - 'storeManager' => $storeManager, |
| 403 | + 'storeManager' => $this->storeManager, |
398 | 404 | 'resource' => $this->resource,
|
399 | 405 | 'registry' => $this->registry,
|
400 | 406 | 'moduleManager' => $this->moduleManager,
|
@@ -450,6 +456,48 @@ public function testGetStoreIds()
|
450 | 456 | $this->assertEquals($expectedStoreIds, $this->model->getStoreIds());
|
451 | 457 | }
|
452 | 458 |
|
| 459 | + /** |
| 460 | + * @dataProvider getSingleStoreIds |
| 461 | + * @param bool $isObjectNew |
| 462 | + */ |
| 463 | + public function testGetStoreSingleSiteModelIds( |
| 464 | + bool $isObjectNew |
| 465 | + ) { |
| 466 | + $websiteIDs = [0 => 2]; |
| 467 | + $this->model->setWebsiteIds( |
| 468 | + !$isObjectNew ? $websiteIDs : array_flip($websiteIDs) |
| 469 | + ); |
| 470 | + |
| 471 | + $this->model->isObjectNew($isObjectNew); |
| 472 | + |
| 473 | + $this->storeManager->expects( |
| 474 | + $this->exactly( |
| 475 | + (int) !$isObjectNew |
| 476 | + ) |
| 477 | + ) |
| 478 | + ->method('isSingleStoreMode') |
| 479 | + ->will($this->returnValue(true)); |
| 480 | + |
| 481 | + $this->website->expects( |
| 482 | + $this->once() |
| 483 | + )->method('getStoreIds') |
| 484 | + ->will($this->returnValue($websiteIDs)); |
| 485 | + |
| 486 | + $this->assertEquals($websiteIDs, $this->model->getStoreIds()); |
| 487 | + } |
| 488 | + |
| 489 | + public function getSingleStoreIds() |
| 490 | + { |
| 491 | + return [ |
| 492 | + [ |
| 493 | + false |
| 494 | + ], |
| 495 | + [ |
| 496 | + true |
| 497 | + ], |
| 498 | + ]; |
| 499 | + } |
| 500 | + |
453 | 501 | public function testGetStoreId()
|
454 | 502 | {
|
455 | 503 | $this->model->setStoreId(3);
|
@@ -1221,8 +1269,7 @@ public function testGetMediaGalleryImagesMerging()
|
1221 | 1269 | {
|
1222 | 1270 | $mediaEntries =
|
1223 | 1271 | [
|
1224 |
| - 'images' => |
1225 |
| - [ |
| 1272 | + 'images' => [ |
1226 | 1273 | [
|
1227 | 1274 | 'value_id' => 1,
|
1228 | 1275 | 'file' => 'imageFile.jpg',
|
|
0 commit comments