ShippingMethodManagementTest.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Quote\Test\Unit\Model;
  8. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  9. use Magento\Quote\Api\Data\ShippingMethodInterface;
  10. use Magento\Quote\Model\Cart\ShippingMethodConverter;
  11. use Magento\Quote\Model\Quote;
  12. use Magento\Quote\Model\Quote\Address;
  13. use Magento\Quote\Model\Quote\Address\Rate;
  14. use Magento\Quote\Model\Quote\TotalsCollector;
  15. use Magento\Quote\Model\QuoteRepository;
  16. use Magento\Quote\Model\ResourceModel\Quote\Address as QuoteAddressResource;
  17. use Magento\Quote\Model\ShippingMethodManagement;
  18. use Magento\Store\Model\Store;
  19. use PHPUnit_Framework_MockObject_MockObject as MockObject;
  20. /**
  21. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  22. */
  23. class ShippingMethodManagementTest extends \PHPUnit\Framework\TestCase
  24. {
  25. /**
  26. * @var ShippingMethodManagement
  27. */
  28. protected $model;
  29. /**
  30. * @var \PHPUnit_Framework_MockObject_MockObject
  31. */
  32. protected $shippingMethodMock;
  33. /**
  34. * @var \PHPUnit_Framework_MockObject_MockObject
  35. */
  36. protected $methodDataFactoryMock;
  37. /**
  38. * @var ShippingMethodConverter|MockObject
  39. */
  40. protected $converter;
  41. /**
  42. * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
  43. */
  44. protected $objectManager;
  45. /**
  46. * @var QuoteRepository|MockObject
  47. */
  48. private $quoteRepository;
  49. /**
  50. * @var Quote|MockObject
  51. */
  52. private $quote;
  53. /**
  54. * @var Address|MockObject
  55. */
  56. private $shippingAddress;
  57. /**
  58. * @var \Magento\Framework\Reflection\DataObjectProcessor|MockObject
  59. */
  60. private $dataProcessor;
  61. /**
  62. * @var \Magento\Customer\Api\Data\AddressInterfaceFactory|MockObject
  63. */
  64. private $addressFactory;
  65. /**
  66. * @var \Magento\Customer\Api\AddressRepositoryInterface|MockObject
  67. */
  68. private $addressRepository;
  69. /**
  70. * @var TotalsCollector|MockObject
  71. */
  72. private $totalsCollector;
  73. /**
  74. * @var Store|MockObject
  75. */
  76. private $storeMock;
  77. /**
  78. * @var QuoteAddressResource|MockObject
  79. */
  80. private $quoteAddressResource;
  81. protected function setUp()
  82. {
  83. $this->objectManager = new ObjectManager($this);
  84. $this->quoteRepository = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class);
  85. $this->addressRepository = $this->createMock(\Magento\Customer\Api\AddressRepositoryInterface::class);
  86. $className = \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory::class;
  87. $this->methodDataFactoryMock = $this->createPartialMock($className, ['create']);
  88. $className = \Magento\Customer\Api\Data\AddressInterfaceFactory::class;
  89. $this->addressFactory = $this->createPartialMock($className, ['create']);
  90. $className = \Magento\Framework\Reflection\DataObjectProcessor::class;
  91. $this->dataProcessor = $this->createMock($className);
  92. $this->quoteAddressResource = $this->createMock(QuoteAddressResource::class);
  93. $this->storeMock = $this->createMock(Store::class);
  94. $this->quote = $this->getMockBuilder(Quote::class)
  95. ->disableOriginalConstructor()
  96. ->setMethods([
  97. 'getShippingAddress',
  98. 'isVirtual',
  99. 'getItemsCount',
  100. 'getQuoteCurrencyCode',
  101. 'getBillingAddress',
  102. 'collectTotals',
  103. 'save',
  104. '__wakeup',
  105. ])
  106. ->getMock();
  107. $this->shippingAddress = $this->getMockBuilder(Address::class)
  108. ->disableOriginalConstructor()
  109. ->setMethods([
  110. 'getCountryId',
  111. 'getShippingMethod',
  112. 'getShippingDescription',
  113. 'getShippingAmount',
  114. 'getBaseShippingAmount',
  115. 'getGroupedAllShippingRates',
  116. 'collectShippingRates',
  117. 'requestShippingRates',
  118. 'setShippingMethod',
  119. 'getShippingRateByCode',
  120. 'addData',
  121. 'setCollectShippingRates',
  122. '__wakeup',
  123. ])
  124. ->getMock();
  125. $this->converter = $this->getMockBuilder(ShippingMethodConverter::class)
  126. ->disableOriginalConstructor()
  127. ->setMethods(['modelToDataObject'])
  128. ->getMock();
  129. $this->totalsCollector = $this->getMockBuilder(TotalsCollector::class)
  130. ->disableOriginalConstructor()
  131. ->setMethods(['collectAddressTotals'])
  132. ->getMock();
  133. $this->model = $this->objectManager->getObject(
  134. ShippingMethodManagement::class,
  135. [
  136. 'quoteRepository' => $this->quoteRepository,
  137. 'methodDataFactory' => $this->methodDataFactoryMock,
  138. 'converter' => $this->converter,
  139. 'totalsCollector' => $this->totalsCollector,
  140. 'addressRepository' => $this->addressRepository,
  141. 'quoteAddressResource' => $this->quoteAddressResource,
  142. ]
  143. );
  144. $this->objectManager->setBackwardCompatibleProperty(
  145. $this->model,
  146. 'addressFactory',
  147. $this->addressFactory
  148. );
  149. $this->objectManager->setBackwardCompatibleProperty(
  150. $this->model,
  151. 'dataProcessor',
  152. $this->dataProcessor
  153. );
  154. }
  155. /**
  156. * @expectedException \Magento\Framework\Exception\StateException
  157. * @expectedExceptionMessage The shipping address is missing. Set the address and try again.
  158. */
  159. public function testGetMethodWhenShippingAddressIsNotSet()
  160. {
  161. $cartId = 666;
  162. $this->quoteRepository->expects($this->once())
  163. ->method('getActive')->with($cartId)->will($this->returnValue($this->quote));
  164. $this->quote->expects($this->once())
  165. ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
  166. $this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(null));
  167. $this->assertNull($this->model->get($cartId));
  168. }
  169. public function testGetMethod()
  170. {
  171. $cartId = 666;
  172. $countryId = 1;
  173. $currencyCode = 'US_dollar';
  174. $this->quoteRepository->expects($this->once())
  175. ->method('getActive')->with($cartId)->will($this->returnValue($this->quote));
  176. $this->quote->expects($this->once())
  177. ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
  178. $this->quote->expects($this->once())
  179. ->method('getQuoteCurrencyCode')->willReturn($currencyCode);
  180. $this->shippingAddress->expects($this->any())
  181. ->method('getCountryId')->will($this->returnValue($countryId));
  182. $this->shippingAddress->expects($this->any())
  183. ->method('getShippingMethod')->will($this->returnValue('one_two'));
  184. $this->shippingAddress->expects($this->once())->method('collectShippingRates')->willReturnSelf();
  185. $shippingRateMock = $this->createMock(\Magento\Quote\Model\Quote\Address\Rate::class);
  186. $this->shippingAddress->expects($this->once())
  187. ->method('getShippingRateByCode')
  188. ->with('one_two')
  189. ->willReturn($shippingRateMock);
  190. $this->shippingMethodMock = $this->createMock(\Magento\Quote\Api\Data\ShippingMethodInterface::class);
  191. $this->converter->expects($this->once())
  192. ->method('modelToDataObject')
  193. ->with($shippingRateMock, $currencyCode)
  194. ->willReturn($this->shippingMethodMock);
  195. $this->model->get($cartId);
  196. }
  197. public function testGetMethodIfMethodIsNotSet()
  198. {
  199. $cartId = 666;
  200. $countryId = 1;
  201. $this->quoteRepository->expects($this->once())
  202. ->method('getActive')->with($cartId)->will($this->returnValue($this->quote));
  203. $this->quote->expects($this->once())
  204. ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
  205. $this->shippingAddress->expects($this->any())
  206. ->method('getCountryId')->will($this->returnValue($countryId));
  207. $this->shippingAddress->expects($this->any())
  208. ->method('getShippingMethod')->will($this->returnValue(null));
  209. $this->assertNull($this->model->get($cartId));
  210. }
  211. public function testGetListForVirtualCart()
  212. {
  213. $cartId = 834;
  214. $this->quoteRepository->expects($this->once())
  215. ->method('getActive')->with($cartId)->will($this->returnValue($this->quote));
  216. $this->quote->expects($this->once())
  217. ->method('isVirtual')->will($this->returnValue(true));
  218. $this->assertEquals([], $this->model->getList($cartId));
  219. }
  220. public function testGetListForEmptyCart()
  221. {
  222. $cartId = 834;
  223. $this->quoteRepository->expects($this->once())
  224. ->method('getActive')->with($cartId)->will($this->returnValue($this->quote));
  225. $this->quote->expects($this->once())
  226. ->method('isVirtual')->will($this->returnValue(false));
  227. $this->quote->expects($this->once())
  228. ->method('getItemsCount')->will($this->returnValue(0));
  229. $this->assertEquals([], $this->model->getList($cartId));
  230. }
  231. /**
  232. * @expectedException \Magento\Framework\Exception\StateException
  233. * @expectedExceptionMessage The shipping address is missing. Set the address and try again.
  234. */
  235. public function testGetListWhenShippingAddressIsNotSet()
  236. {
  237. $cartId = 834;
  238. $this->quoteRepository->expects($this->once())
  239. ->method('getActive')->with($cartId)->will($this->returnValue($this->quote));
  240. $this->quote->expects($this->once())
  241. ->method('isVirtual')->will($this->returnValue(false));
  242. $this->quote->expects($this->once())
  243. ->method('getItemsCount')->will($this->returnValue(3));
  244. $this->quote->expects($this->once())
  245. ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
  246. $this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(null));
  247. $this->model->getList($cartId);
  248. }
  249. public function testGetList()
  250. {
  251. $cartId = 834;
  252. $this->quoteRepository->expects($this->once())
  253. ->method('getActive')->with($cartId)->will($this->returnValue($this->quote));
  254. $this->quote->expects($this->once())
  255. ->method('isVirtual')->will($this->returnValue(false));
  256. $this->quote->expects($this->once())
  257. ->method('getItemsCount')->will($this->returnValue(3));
  258. $this->quote->expects($this->once())
  259. ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
  260. $this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(345));
  261. $this->shippingAddress->expects($this->once())->method('collectShippingRates');
  262. $shippingRateMock = $this->createMock(\Magento\Quote\Model\Quote\Address\Rate::class);
  263. $this->shippingAddress->expects($this->once())
  264. ->method('getGroupedAllShippingRates')
  265. ->will($this->returnValue([[$shippingRateMock]]));
  266. $currencyCode = 'EUR';
  267. $this->quote->expects($this->once())
  268. ->method('getQuoteCurrencyCode')
  269. ->will($this->returnValue($currencyCode));
  270. $this->converter->expects($this->once())
  271. ->method('modelToDataObject')
  272. ->with($shippingRateMock, $currencyCode)
  273. ->will($this->returnValue('RateValue'));
  274. $this->assertEquals(['RateValue'], $this->model->getList($cartId));
  275. }
  276. /**
  277. * @expectedException \Magento\Framework\Exception\InputException
  278. * @expectedExceptionMessage The shipping method can't be set for an empty cart. Add an item to cart and try again.
  279. */
  280. public function testSetMethodWithInputException()
  281. {
  282. $cartId = 12;
  283. $carrierCode = 34;
  284. $methodCode = 56;
  285. $this->quoteRepository->expects($this->exactly(2))
  286. ->method('getActive')
  287. ->with($cartId)
  288. ->willReturn($this->quote);
  289. $this->quote->expects($this->once())->method('getItemsCount')->will($this->returnValue(0));
  290. $this->quote->expects($this->never())->method('isVirtual');
  291. $this->model->set($cartId, $carrierCode, $methodCode);
  292. }
  293. /**
  294. * @expectedException \Magento\Framework\Exception\NoSuchEntityException
  295. * @expectedExceptionMessage The Cart includes virtual product(s) only, so a shipping address is not used.
  296. */
  297. public function testSetMethodWithVirtualProduct()
  298. {
  299. $cartId = 12;
  300. $carrierCode = 34;
  301. $methodCode = 56;
  302. $this->quoteRepository->expects($this->exactly(2))
  303. ->method('getActive')
  304. ->with($cartId)
  305. ->willReturn($this->quote);
  306. $this->quote->expects($this->once())->method('getItemsCount')->will($this->returnValue(1));
  307. $this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(true));
  308. $this->model->set($cartId, $carrierCode, $methodCode);
  309. }
  310. /**
  311. * @expectedException \Magento\Framework\Exception\StateException
  312. * @expectedExceptionMessage The shipping address is missing. Set the address and try again.
  313. */
  314. public function testSetMethodWithoutShippingAddress()
  315. {
  316. $cartId = 12;
  317. $carrierCode = 34;
  318. $methodCode = 56;
  319. $this->quoteRepository->expects($this->exactly(2))
  320. ->method('getActive')
  321. ->with($cartId)
  322. ->willReturn($this->quote);
  323. $this->quote->expects($this->once())->method('getItemsCount')->will($this->returnValue(1));
  324. $this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(false));
  325. $this->quote->expects($this->once())
  326. ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
  327. $this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(null));
  328. $this->quoteAddressResource->expects($this->once())->method('delete')->with($this->shippingAddress);
  329. $this->model->set($cartId, $carrierCode, $methodCode);
  330. }
  331. /**
  332. * @expectedException \Magento\Framework\Exception\CouldNotSaveException
  333. * @expectedExceptionMessage The shipping method can't be set. Custom Error
  334. */
  335. public function testSetMethodWithCouldNotSaveException()
  336. {
  337. $cartId = 12;
  338. $carrierCode = 34;
  339. $methodCode = 56;
  340. $countryId = 1;
  341. $this->quoteRepository->expects($this->exactly(2))
  342. ->method('getActive')
  343. ->with($cartId)
  344. ->willReturn($this->quote);
  345. $this->quote->expects($this->once())->method('getItemsCount')->will($this->returnValue(1));
  346. $this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(false));
  347. $this->quote->expects($this->once())
  348. ->method('getShippingAddress')
  349. ->willReturn($this->shippingAddress);
  350. $this->shippingAddress->expects($this->once())
  351. ->method('getCountryId')
  352. ->willReturn($countryId);
  353. $this->shippingAddress->expects($this->once())
  354. ->method('setShippingMethod')
  355. ->with($carrierCode . '_' . $methodCode);
  356. $exception = new \Exception('Custom Error');
  357. $this->quote->expects($this->once())->method('collectTotals')->willReturnSelf();
  358. $this->quoteRepository->expects($this->once())
  359. ->method('save')
  360. ->with($this->quote)
  361. ->willThrowException($exception);
  362. $this->model->set($cartId, $carrierCode, $methodCode);
  363. }
  364. /**
  365. * @expectedException \Magento\Framework\Exception\StateException
  366. * @expectedExceptionMessage The shipping address is missing. Set the address and try again.
  367. */
  368. public function testSetMethodWithoutAddress()
  369. {
  370. $cartId = 12;
  371. $carrierCode = 34;
  372. $methodCode = 56;
  373. $this->quoteRepository->expects($this->exactly(2))
  374. ->method('getActive')
  375. ->with($cartId)
  376. ->willReturn($this->quote);
  377. $this->quote->expects($this->once())->method('getItemsCount')->will($this->returnValue(1));
  378. $this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(false));
  379. $this->quote->expects($this->once())
  380. ->method('getShippingAddress')
  381. ->willReturn($this->shippingAddress);
  382. $this->shippingAddress->expects($this->once())->method('getCountryId');
  383. $this->quoteAddressResource->expects($this->once())->method('delete')->with($this->shippingAddress);
  384. $this->model->set($cartId, $carrierCode, $methodCode);
  385. }
  386. public function testSetMethod()
  387. {
  388. $cartId = 12;
  389. $carrierCode = 34;
  390. $methodCode = 56;
  391. $countryId = 1;
  392. $this->quoteRepository->expects($this->exactly(2))
  393. ->method('getActive')
  394. ->with($cartId)
  395. ->willReturn($this->quote);
  396. $this->quote->expects($this->once())->method('getItemsCount')->will($this->returnValue(1));
  397. $this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(false));
  398. $this->quote->expects($this->once())
  399. ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress));
  400. $this->shippingAddress->expects($this->once())
  401. ->method('getCountryId')->will($this->returnValue($countryId));
  402. $this->shippingAddress->expects($this->once())
  403. ->method('setShippingMethod')->with($carrierCode . '_' . $methodCode);
  404. $this->quote->expects($this->once())->method('collectTotals')->will($this->returnSelf());
  405. $this->quoteRepository->expects($this->once())->method('save')->with($this->quote);
  406. $this->assertTrue($this->model->set($cartId, $carrierCode, $methodCode));
  407. }
  408. /**
  409. * @covers \Magento\Quote\Model\ShippingMethodManagement::estimateByExtendedAddress
  410. */
  411. public function testEstimateByExtendedAddress()
  412. {
  413. $cartId = 1;
  414. $addressData = [
  415. 'region' => 'California',
  416. 'region_id' => 23,
  417. 'country_id' => 1,
  418. 'postcode' => 90200,
  419. ];
  420. $currencyCode = 'UAH';
  421. /**
  422. * @var \Magento\Quote\Api\Data\AddressInterface|MockObject $address
  423. */
  424. $address = $this->getMockBuilder(Address::class)
  425. ->disableOriginalConstructor()
  426. ->getMock();
  427. $this->addressFactory->expects($this->any())
  428. ->method('create')
  429. ->will($this->returnValue($address));
  430. $this->quoteRepository->expects(static::once())
  431. ->method('getActive')
  432. ->with($cartId)
  433. ->willReturn($this->quote);
  434. $this->quote->expects(static::once())
  435. ->method('isVirtual')
  436. ->willReturn(false);
  437. $this->quote->expects(static::once())
  438. ->method('getItemsCount')
  439. ->willReturn(1);
  440. $this->quote->expects(static::once())
  441. ->method('getShippingAddress')
  442. ->willReturn($this->shippingAddress);
  443. $this->dataProcessor->expects(static::any())
  444. ->method('buildOutputDataArray')
  445. ->willReturn($addressData);
  446. $this->shippingAddress->expects(static::once())
  447. ->method('setCollectShippingRates')
  448. ->with(true)
  449. ->willReturnSelf();
  450. $this->totalsCollector->expects(static::once())
  451. ->method('collectAddressTotals')
  452. ->with($this->quote, $this->shippingAddress)
  453. ->willReturnSelf();
  454. $rate = $this->getMockBuilder(Rate::class)
  455. ->disableOriginalConstructor()
  456. ->setMethods([])
  457. ->getMock();
  458. $methodObject = $this->getMockForAbstractClass(ShippingMethodInterface::class);
  459. $expectedRates = [$methodObject];
  460. $this->shippingAddress->expects(static::once())
  461. ->method('getGroupedAllShippingRates')
  462. ->willReturn([[$rate]]);
  463. $this->quote->expects(static::once())
  464. ->method('getQuoteCurrencyCode')
  465. ->willReturn($currencyCode);
  466. $this->converter->expects(static::once())
  467. ->method('modelToDataObject')
  468. ->with($rate, $currencyCode)
  469. ->willReturn($methodObject);
  470. $carriersRates = $this->model->estimateByExtendedAddress($cartId, $address);
  471. static::assertEquals($expectedRates, $carriersRates);
  472. }
  473. /**
  474. * @covers \Magento\Quote\Model\ShippingMethodManagement::estimateByAddressId
  475. */
  476. public function testEstimateByAddressId()
  477. {
  478. $cartId = 1;
  479. $addressData = [
  480. 'region' => 'California',
  481. 'region_id' => 23,
  482. 'country_id' => 1,
  483. 'postcode' => 90200,
  484. ];
  485. $currencyCode = 'UAH';
  486. /**
  487. * @var \Magento\Customer\Api\Data\AddressInterface|MockObject $address
  488. */
  489. $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class)
  490. ->disableOriginalConstructor()
  491. ->getMock();
  492. $this->addressRepository->expects($this->any())
  493. ->method('getById')
  494. ->will($this->returnValue($address));
  495. $this->addressFactory->expects($this->any())
  496. ->method('create')
  497. ->will($this->returnValue($address));
  498. $this->quoteRepository->expects(static::once())
  499. ->method('getActive')
  500. ->with($cartId)
  501. ->willReturn($this->quote);
  502. $this->quote->expects(static::once())
  503. ->method('isVirtual')
  504. ->willReturn(false);
  505. $this->quote->expects(static::once())
  506. ->method('getItemsCount')
  507. ->willReturn(1);
  508. $this->quote->expects(static::once())
  509. ->method('getShippingAddress')
  510. ->willReturn($this->shippingAddress);
  511. $this->dataProcessor->expects(static::any())
  512. ->method('buildOutputDataArray')
  513. ->willReturn($addressData);
  514. $this->shippingAddress->expects(static::once())
  515. ->method('setCollectShippingRates')
  516. ->with(true)
  517. ->willReturnSelf();
  518. $this->totalsCollector->expects(static::once())
  519. ->method('collectAddressTotals')
  520. ->with($this->quote, $this->shippingAddress)
  521. ->willReturnSelf();
  522. $rate = $this->getMockBuilder(Rate::class)
  523. ->disableOriginalConstructor()
  524. ->setMethods([])
  525. ->getMock();
  526. $methodObject = $this->getMockForAbstractClass(ShippingMethodInterface::class);
  527. $expectedRates = [$methodObject];
  528. $this->shippingAddress->expects(static::once())
  529. ->method('getGroupedAllShippingRates')
  530. ->willReturn([[$rate]]);
  531. $this->quote->expects(static::once())
  532. ->method('getQuoteCurrencyCode')
  533. ->willReturn($currencyCode);
  534. $this->converter->expects(static::once())
  535. ->method('modelToDataObject')
  536. ->with($rate, $currencyCode)
  537. ->willReturn($methodObject);
  538. $carriersRates = $this->model->estimateByAddressId($cartId, $address);
  539. static::assertEquals($expectedRates, $carriersRates);
  540. }
  541. }