|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright © Magento, Inc. All rights reserved. |
4 |
| - * See COPYING.txt for license details. |
| 3 | + * Copyright 2013 Adobe |
| 4 | + * All Rights Reserved. |
5 | 5 | */
|
6 | 6 | declare(strict_types=1);
|
7 | 7 |
|
8 | 8 | namespace Magento\Sales\Test\Unit\Model;
|
9 | 9 |
|
10 | 10 | use Magento\Catalog\Api\Data\ProductInterface;
|
| 11 | +use Magento\Catalog\Model\Product; |
| 12 | +use Magento\Catalog\Model\Product\Type; |
11 | 13 | use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
|
12 | 14 | use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
|
13 | 15 | use Magento\Framework\Api\SearchCriteria;
|
@@ -213,6 +215,49 @@ protected function setUp(): void
|
213 | 215 | );
|
214 | 216 | }
|
215 | 217 |
|
| 218 | + /** |
| 219 | + * @return void |
| 220 | + * @throws \PHPUnit\Framework\MockObject\Exception |
| 221 | + */ |
| 222 | + public function testCanShipBundleWithToghetherShipment(): void |
| 223 | + { |
| 224 | + $this->order->setActionFlag($this->order::ACTION_FLAG_UNHOLD, false); |
| 225 | + $this->order->setActionFlag($this->order::ACTION_FLAG_SHIP, true); |
| 226 | + |
| 227 | + $bundleItem = $this->createMock(Item::class); |
| 228 | + $bundleItem->expects($this->any())->method('getParentItem')->willReturn(null); |
| 229 | + $bundleItem->expects($this->exactly(2))->method('getQtyToShip')->willReturn(0); |
| 230 | + $bundleItem->expects($this->any())->method('getProductType')->willReturn(Type::TYPE_BUNDLE); |
| 231 | + |
| 232 | + $product = $this->getMockBuilder(Product::class) |
| 233 | + ->disableOriginalConstructor() |
| 234 | + ->addMethods(['getShipmentType']) |
| 235 | + ->getMock(); |
| 236 | + $product->expects($this->any()) |
| 237 | + ->method('getShipmentType') |
| 238 | + ->willReturn(Type\AbstractType::SHIPMENT_TOGETHER); |
| 239 | + $bundleItem->expects($this->any())->method('getProduct')->willReturn($product); |
| 240 | + |
| 241 | + $childProduct = $this->createMock(Item::class); |
| 242 | + $childProduct->expects($this->any())->method('getParentItem')->willReturn($bundleItem); |
| 243 | + |
| 244 | + $orderItems = [$bundleItem, $childProduct]; |
| 245 | + $this->searchCriteriaBuilder->expects($this->once())->method('addFilter')->willReturnSelf(); |
| 246 | + |
| 247 | + $searchCriteria = $this->getMockBuilder(SearchCriteria::class) |
| 248 | + ->disableOriginalConstructor() |
| 249 | + ->getMockForAbstractClass(); |
| 250 | + $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria); |
| 251 | + $itemsCollection = $this->getMockBuilder(OrderItemSearchResultInterface::class) |
| 252 | + ->onlyMethods(['getItems']) |
| 253 | + ->disableOriginalConstructor() |
| 254 | + ->getMockForAbstractClass(); |
| 255 | + $itemsCollection->expects($this->once())->method('getItems')->willReturn($orderItems); |
| 256 | + $this->itemRepository->expects($this->once())->method('getList')->willReturn($itemsCollection); |
| 257 | + |
| 258 | + $this->assertFalse($this->order->canShip()); |
| 259 | + } |
| 260 | + |
216 | 261 | /**
|
217 | 262 | * Test testGetItems method.
|
218 | 263 | */
|
|
0 commit comments