Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GuestShippingAddressManagementTest.php
Go to the documentation of this file.
1 <?php
8 
9 class GuestShippingAddressManagementTest extends \PHPUnit\Framework\TestCase
10 {
14  protected $model;
15 
19  protected $quoteAddressMock;
20 
25 
29  protected $quoteIdMaskMock;
30 
35 
39  protected $maskedCartId;
40 
44  protected $cartId;
45 
46  protected function setUp()
47  {
48  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
49 
50  $this->shippingAddressManagementMock = $this->createMock(
51  \Magento\Quote\Model\ShippingAddressManagementInterface::class
52  );
53  $this->quoteAddressMock = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
54 
55  $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73';
56  $this->cartId = 123;
57 
58  $guestCartTestHelper = new GuestCartTestHelper($this);
59  list($this->quoteIdMaskFactoryMock, $this->quoteIdMaskMock) = $guestCartTestHelper->mockQuoteIdMask(
60  $this->maskedCartId,
61  $this->cartId
62  );
63 
64  $this->model = $objectManager->getObject(
65  \Magento\Quote\Model\GuestCart\GuestShippingAddressManagement::class,
66  [
67  'shippingAddressManagement' => $this->shippingAddressManagementMock,
68  'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock
69  ]
70  );
71  }
72 
73  public function testAssign()
74  {
75  $addressId = 1;
76  $this->shippingAddressManagementMock->expects($this->once())->method('assign')->willReturn($addressId);
77  $this->assertEquals($addressId, $this->model->assign($this->maskedCartId, $this->quoteAddressMock));
78  }
79 
80  public function testGet()
81  {
82  $this->shippingAddressManagementMock->expects($this->once())->method('get')->willReturn(
83  $this->quoteAddressMock
84  );
85  $this->assertEquals($this->quoteAddressMock, $this->model->get($this->maskedCartId));
86  }
87 }
$objectManager
Definition: bootstrap.php:17