34 private $collectionProcessorMock;
38 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
40 $this->searchResultFactory = $this->getMockBuilder(
41 \
Magento\Sales\Api\
Data\InvoiceSearchResultInterfaceFactory::class
43 ->disableOriginalConstructor()
44 ->setMethods([
'create'])
46 $this->collectionProcessorMock = $this->getMockBuilder(CollectionProcessorInterface::class)
51 'invoiceMetadata' => $this->invoiceMetadata,
52 'searchResultFactory' => $this->searchResultFactory,
53 'collectionProcessor' => $this->collectionProcessorMock,
56 $this->type = $this->createPartialMock(\
Magento\Eav\Model\Entity\Type::class, [
'fetchNewIncrementId']);
64 ->disableOriginalConstructor()
71 ->method(
'getEntityId')
74 $this->invoiceMetadata->expects($this->once())
75 ->method(
'getNewInstance')
78 $this->assertEquals(
$entity, $this->invoice->get(
$id));
87 $this->invoice->get(
null);
99 ->disableOriginalConstructor()
101 $entity->expects($this->once())
105 $entity->expects($this->once())
106 ->method(
'getEntityId')
109 $this->invoiceMetadata->expects($this->once())
110 ->method(
'getNewInstance')
113 $this->assertNull(
$entity, $this->invoice->get(
$id));
119 ->disableOriginalConstructor()
121 $this->invoiceMetadata->expects($this->once())
122 ->method(
'getNewInstance')
124 $this->assertEquals(
$entity, $this->invoice->create());
130 ->disableOriginalConstructor()
133 ->disableOriginalConstructor()
135 $this->collectionProcessorMock->expects($this->once())
138 $this->searchResultFactory->expects($this->once())
148 ->disableOriginalConstructor()
150 $entity->expects($this->once())
151 ->method(
'getEntityId')
155 ->disableOriginalConstructor()
157 $mapper->expects($this->once())
161 $this->invoiceMetadata->expects($this->any())
162 ->method(
'getMapper')
163 ->willReturn($mapper);
165 $this->assertTrue($this->invoice->delete(
$entity));
173 ->disableOriginalConstructor()
175 $entity->expects($this->once())
180 ->method(
'getEntityId')
183 $this->invoiceMetadata->expects($this->once())
184 ->method(
'getNewInstance')
188 ->disableOriginalConstructor()
190 $mapper->expects($this->once())
194 $this->invoiceMetadata->expects($this->any())
195 ->method(
'getMapper')
196 ->willReturn($mapper);
198 $this->assertTrue($this->invoice->deleteById(
$id));
204 ->disableOriginalConstructor()
207 ->method(
'getEntityId')
211 ->disableOriginalConstructor()
213 $mapper->expects($this->once())
217 $this->invoiceMetadata->expects($this->any())
218 ->method(
'getMapper')
219 ->willReturn($mapper);