CarrierTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Ups\Model;
  7. use Magento\TestFramework\Helper\Bootstrap;
  8. use Magento\Quote\Model\Quote\Address\RateRequestFactory;
  9. class CarrierTest extends \PHPUnit\Framework\TestCase
  10. {
  11. /**
  12. * @var Carrier
  13. */
  14. private $carrier;
  15. /**
  16. * @return void
  17. */
  18. protected function setUp()
  19. {
  20. $this->carrier = Bootstrap::getObjectManager()->create(Carrier::class);
  21. }
  22. /**
  23. * @return void
  24. */
  25. public function testGetShipAcceptUrl()
  26. {
  27. $this->assertEquals('https://wwwcie.ups.com/ups.app/xml/ShipAccept', $this->carrier->getShipAcceptUrl());
  28. }
  29. /**
  30. * Test ship accept url for live site
  31. *
  32. * @magentoConfigFixture current_store carriers/ups/is_account_live 1
  33. */
  34. public function testGetShipAcceptUrlLive()
  35. {
  36. $this->assertEquals('https://onlinetools.ups.com/ups.app/xml/ShipAccept', $this->carrier->getShipAcceptUrl());
  37. }
  38. /**
  39. * @return void
  40. */
  41. public function testGetShipConfirmUrl()
  42. {
  43. $this->assertEquals('https://wwwcie.ups.com/ups.app/xml/ShipConfirm', $this->carrier->getShipConfirmUrl());
  44. }
  45. /**
  46. * Test ship accept url for live site
  47. *
  48. * @magentoConfigFixture current_store carriers/ups/is_account_live 1
  49. */
  50. public function testGetShipConfirmUrlLive()
  51. {
  52. $this->assertEquals(
  53. 'https://onlinetools.ups.com/ups.app/xml/ShipConfirm',
  54. $this->carrier->getShipConfirmUrl()
  55. );
  56. }
  57. /**
  58. * @magentoConfigFixture current_store carriers/ups/active 1
  59. * @magentoConfigFixture current_store carriers/ups/allowed_methods 1DA,GND
  60. * @magentoConfigFixture current_store carriers/ups/free_method GND
  61. */
  62. public function testCollectFreeRates()
  63. {
  64. $this->markTestSkipped('Test is blocked by MAGETWO-97467.');
  65. $rateRequest = Bootstrap::getObjectManager()->get(RateRequestFactory::class)->create();
  66. $rateRequest->setDestCountryId('US');
  67. $rateRequest->setDestRegionId('CA');
  68. $rateRequest->setDestPostcode('90001');
  69. $rateRequest->setPackageQty(1);
  70. $rateRequest->setPackageWeight(1);
  71. $rateRequest->setFreeMethodWeight(0);
  72. $rateRequest->setLimitCarrier($this->carrier::CODE);
  73. $rateRequest->setFreeShipping(true);
  74. $rateResult = $this->carrier->collectRates($rateRequest);
  75. $result = $rateResult->asArray();
  76. $methods = $result[$this->carrier::CODE]['methods'];
  77. $this->assertEquals(0, $methods['GND']['price']);
  78. $this->assertNotEquals(0, $methods['1DA']['price']);
  79. }
  80. }