62 $this->commentRepositoryMock = $this->getMockForAbstractClass(
63 \
Magento\Sales\Api\ShipmentCommentRepositoryInterface::class,
68 $this->searchCriteriaBuilderMock = $this->createPartialMock(
69 \
Magento\Framework\Api\SearchCriteriaBuilder::class,
70 [
'create',
'addFilters']
72 $this->filterBuilderMock = $this->createPartialMock(
73 \
Magento\Framework\Api\FilterBuilder::class,
74 [
'setField',
'setValue',
'setConditionType',
'create']
76 $this->repositoryMock = $this->getMockForAbstractClass(
77 \
Magento\Sales\Api\ShipmentRepositoryInterface::class,
82 $this->notifierMock = $this->createPartialMock(\
Magento\
Shipping\Model\ShipmentNotifier::class, [
'notify']);
85 \
Magento\Sales\Model\Service\ShipmentService::class,
87 'commentRepository' => $this->commentRepositoryMock,
88 'criteriaBuilder' => $this->searchCriteriaBuilderMock,
89 'filterBuilder' => $this->filterBuilderMock,
90 'repository' => $this->repositoryMock,
91 'notifier' => $this->notifierMock,
102 $returnValue =
'return-value';
104 $shipmentMock = $this->createPartialMock(\
Magento\Sales\Model\
Order\Shipment::class, [
'getShippingLabel']);
106 $this->repositoryMock->expects($this->once())
109 ->will($this->returnValue($shipmentMock));
110 $shipmentMock->expects($this->once())
111 ->method(
'getShippingLabel')
112 ->will($this->returnValue($returnValue));
114 $this->assertEquals($returnValue, $this->shipmentService->getLabel(
$id));
123 $returnValue =
'return-value';
125 $filterMock = $this->createMock(\
Magento\Framework\Api\Filter::class);
126 $searchCriteriaMock = $this->createMock(\
Magento\Framework\Api\SearchCriteria::class);
128 $this->filterBuilderMock->expects($this->once())
131 ->will($this->returnSelf());
132 $this->filterBuilderMock->expects($this->once())
135 ->will($this->returnSelf());
136 $this->filterBuilderMock->expects($this->once())
137 ->method(
'setConditionType')
139 ->will($this->returnSelf());
140 $this->filterBuilderMock->expects($this->once())
142 ->will($this->returnValue($filterMock));
143 $this->searchCriteriaBuilderMock->expects($this->once())
144 ->method(
'addFilters')
145 ->with([$filterMock]);
146 $this->searchCriteriaBuilderMock->expects($this->once())
148 ->will($this->returnValue($searchCriteriaMock));
149 $this->commentRepositoryMock->expects($this->once())
151 ->with($searchCriteriaMock)
152 ->will($this->returnValue($returnValue));
154 $this->assertEquals($returnValue, $this->shipmentService->getCommentsList(
$id));
163 $returnValue =
'return-value';
165 $modelMock = $this->getMockForAbstractClass(
166 \
Magento\Sales\Model\AbstractModel::class,
172 $this->repositoryMock->expects($this->once())
175 ->will($this->returnValue($modelMock));
176 $this->notifierMock->expects($this->once())
179 ->will($this->returnValue($returnValue));
181 $this->assertEquals($returnValue, $this->shipmentService->notify(
$id));
$searchCriteriaBuilderMock