39 private $collectionProcessor;
45 $this->metadata = $this->createPartialMock(
47 [
'getNewInstance',
'getMapper']
50 $this->searchResultFactory = $this->createPartialMock(
51 \
Magento\Sales\Api\
Data\ShipmentSearchResultInterfaceFactory::class,
54 $this->collectionProcessor = $this->createMock(
55 \
Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface::class
60 'metadata' => $this->metadata,
61 'searchResultFactory' => $this->searchResultFactory,
62 'collectionProcessor' => $this->collectionProcessor
75 $this->expectException(\
Magento\Framework\Exception\InputException::class);
77 $this->subject->get(
$id);
79 $shipment = $this->createPartialMock(\
Magento\Sales\Model\
Order\Shipment::class, [
'load',
'getEntityId']);
85 ->method(
'getEntityId')
86 ->willReturn($entityId);
88 $this->metadata->expects($this->once())
89 ->method(
'getNewInstance')
93 $this->expectException(\
Magento\Framework\Exception\NoSuchEntityException::class);
95 $this->subject->get(
$id);
97 $this->assertEquals(
$shipment, $this->subject->get(
$id));
104 ->method(
'getEntityId')
105 ->willReturn($entityId);
107 $this->metadata->expects($this->never())
108 ->method(
'getNewInstance')
112 $this->assertEquals(
$shipment, $this->subject->get(
$id));
134 $this->collectionProcessor->expects($this->once())
137 $this->searchResultFactory->expects($this->once())
148 ->method(
'getEntityId')
151 $mapper = $this->getMockForAbstractClass(
160 $mapper->expects($this->once())
164 $this->metadata->expects($this->any())
165 ->method(
'getMapper')
166 ->willReturn($mapper);
168 $this->assertTrue($this->subject->delete(
$shipment));
179 ->method(
'getEntityId');
181 $mapper = $this->getMockForAbstractClass(
190 $mapper->expects($this->once())
192 ->willThrowException(
new \Exception(
'error'));
194 $this->metadata->expects($this->any())
195 ->method(
'getMapper')
196 ->willReturn($mapper);
205 ->method(
'getEntityId')
208 $mapper = $this->getMockForAbstractClass(
217 $mapper->expects($this->once())
221 $this->metadata->expects($this->any())
222 ->method(
'getMapper')
223 ->willReturn($mapper);
236 ->method(
'getEntityId');
238 $mapper = $this->getMockForAbstractClass(
247 $mapper->expects($this->once())
249 ->willThrowException(
new \Exception(
'error'));
251 $this->metadata->expects($this->any())
252 ->method(
'getMapper')
253 ->willReturn($mapper);
262 $this->metadata->expects($this->once())
263 ->method(
'getNewInstance')
266 $this->assertEquals(
$shipment, $this->subject->create());
testDeleteWithException()
foreach($order->getItems() as $orderItem) $shipment