Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShippingLabelConverterTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 class ShippingLabelConverterTest extends \PHPUnit\Framework\TestCase
14 {
18  private $model;
19 
23  private $shipmentMock;
24 
28  protected function setUp()
29  {
30  $this->model = new \Magento\Sales\Plugin\ShippingLabelConverter();
31 
32  $shippingLabel = 'shipping_label_test';
33  $shippingLabelEncoded = base64_encode('shipping_label_test');
34  $this->shipmentMock = $this->getMockBuilder(\Magento\Sales\Api\Data\ShipmentInterface::class)
35  ->disableOriginalConstructor()->getMock();
36  $this->shipmentMock->expects($this->exactly(2))->method('getShippingLabel')->willReturn($shippingLabel);
37  $this->shipmentMock->expects($this->once())
38  ->method('setShippingLabel')
39  ->with($shippingLabelEncoded)
40  ->willReturnSelf();
41  }
42 
46  public function testAfterGet()
47  {
48  $this->model->afterGet(
49  $this->getMockBuilder(\Magento\Sales\Api\ShipmentRepositoryInterface::class)
50  ->disableOriginalConstructor()->getMock(),
51  $this->shipmentMock
52  );
53  }
54 
58  public function testAfterGetList()
59  {
60  $searchResultMock = $this->getMockBuilder(\Magento\Sales\Api\Data\ShipmentSearchResultInterface::class)
61  ->disableOriginalConstructor()->getMock();
62  $searchResultMock->expects($this->once())->method('getItems')->willReturn([$this->shipmentMock]);
63 
64  $this->model->afterGetList(
65  $this->getMockBuilder(\Magento\Sales\Api\ShipmentRepositoryInterface::class)
66  ->disableOriginalConstructor()->getMock(),
67  $searchResultMock
68  );
69  }
70 }