|
7 | 7 |
|
8 | 8 | namespace Magento\Sales\Test\Unit\Model\Order; |
9 | 9 |
|
10 | | -use Magento\Sales\Model\OrderFactory; |
| 10 | +use Magento\Sales\Api\Data\OrderInterface; |
11 | 11 | use Magento\Sales\Api\Data\ShippingInterfaceFactory; |
12 | 12 | use Magento\Sales\Api\Data\TotalInterfaceFactory; |
| 13 | +use Magento\Sales\Model\OrderFactory; |
13 | 14 | use Magento\Sales\Model\Order\ShippingBuilder; |
14 | 15 | use PHPUnit\Framework\MockObject\MockObject; |
15 | 16 | use PHPUnit\Framework\TestCase; |
@@ -37,16 +38,38 @@ class ShippingBuilderTest extends TestCase |
37 | 38 | private $totalFactory; |
38 | 39 |
|
39 | 40 | /** |
40 | | - * @return void |
| 41 | + * @inheirtDoc |
41 | 42 | */ |
42 | 43 | protected function setUp(): void |
43 | 44 | { |
44 | 45 | $this->orderFactory = $this->getMockBuilder(OrderFactory::class) |
| 46 | + ->disableOriginalConstructor() |
45 | 47 | ->getMock(); |
46 | 48 | $this->shippingFactory = $this->getMockBuilder(ShippingInterfaceFactory::class) |
| 49 | + ->disableOriginalConstructor() |
47 | 50 | ->getMock(); |
48 | 51 | $this->totalFactory = $this->getMockBuilder(TotalInterfaceFactory::class) |
| 52 | + ->disableOriginalConstructor() |
49 | 53 | ->getMock(); |
50 | 54 | $this->shippingBuilder = new ShippingBuilder($this->orderFactory, $this->shippingFactory, $this->totalFactory); |
51 | 55 | } |
| 56 | + |
| 57 | + /** |
| 58 | + * Test for case when order is provided instead of order_id |
| 59 | + * |
| 60 | + * @return void |
| 61 | + */ |
| 62 | + public function testCreateWithOrder() : void |
| 63 | + { |
| 64 | + $order = $this->getMockBuilder(OrderInterface::class) |
| 65 | + ->getMockForAbstractClass(); |
| 66 | + $this->shippingBuilder->setOrder($order); |
| 67 | + $order->expects($this->any()) |
| 68 | + ->method('getEntityId') |
| 69 | + ->willReturn(1); |
| 70 | + $this->orderFactory->expects($this->never()) |
| 71 | + ->method('create'); |
| 72 | + |
| 73 | + $this->shippingBuilder->create(); |
| 74 | + } |
52 | 75 | } |
0 commit comments