Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TrackingTest.php
Go to the documentation of this file.
1 <?php
7 
8 class TrackingTest extends \PHPUnit\Framework\TestCase
9 {
10  public function testLookup()
11  {
12  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
13 
14  $shipment = new \Magento\Framework\DataObject(['store_id' => 1]);
15 
16  $registry = $this->createPartialMock(\Magento\Framework\Registry::class, ['registry']);
17  $registry->expects(
18  $this->once()
19  )->method(
20  'registry'
21  )->with(
22  'current_shipment'
23  )->will(
24  $this->returnValue($shipment)
25  );
26 
27  $carrier = $this->createPartialMock(
28  \Magento\OfflineShipping\Model\Carrier\Freeshipping::class,
29  ['isTrackingAvailable', 'getConfigData']
30  );
31  $carrier->expects($this->once())->method('isTrackingAvailable')->will($this->returnValue(true));
32  $carrier->expects(
33  $this->once()
34  )->method(
35  'getConfigData'
36  )->with(
37  'title'
38  )->will(
39  $this->returnValue('configdata')
40  );
41 
42  $config = $this->createPartialMock(\Magento\Shipping\Model\Config::class, ['getAllCarriers']);
43  $config->expects(
44  $this->once()
45  )->method(
46  'getAllCarriers'
47  )->with(
48  1
49  )->will(
50  $this->returnValue(['free' => $carrier])
51  );
52 
54  $model = $helper->getObject(
55  \Magento\Shipping\Block\Adminhtml\Order\Tracking::class,
56  ['registry' => $registry, 'shippingConfig' => $config]
57  );
58 
59  $this->assertEquals(['custom' => 'Custom Value', 'free' => 'configdata'], $model->getCarriers());
60  }
61 }
$helper
Definition: iframe.phtml:13
$config
Definition: fraud_order.php:17
foreach($order->getItems() as $orderItem) $shipment