|
5 | 5 | */ |
6 | 6 | namespace Magento\Ups\Model; |
7 | 7 |
|
| 8 | +use Magento\TestFramework\Helper\Bootstrap; |
| 9 | +use Magento\Quote\Model\Quote\Address\RateRequestFactory; |
| 10 | + |
8 | 11 | class CarrierTest extends \PHPUnit\Framework\TestCase |
9 | 12 | { |
10 | 13 | /** |
11 | | - * @var \Magento\Ups\Model\Carrier |
| 14 | + * @var Carrier |
12 | 15 | */ |
13 | 16 | private $carrier; |
14 | 17 |
|
15 | 18 | protected function setUp() |
16 | 19 | { |
17 | | - $this->carrier = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( |
18 | | - \Magento\Ups\Model\Carrier::class |
19 | | - ); |
| 20 | + $this->carrier = Bootstrap::getObjectManager()->create(Carrier::class); |
20 | 21 | } |
21 | 22 |
|
22 | 23 | public function testGetShipAcceptUrl() |
@@ -51,4 +52,27 @@ public function testGetShipConfirmUrlLive() |
51 | 52 | $this->carrier->getShipConfirmUrl() |
52 | 53 | ); |
53 | 54 | } |
| 55 | + |
| 56 | + /** |
| 57 | + * @magentoConfigFixture current_store carriers/ups/active 1 |
| 58 | + * @magentoConfigFixture current_store carriers/ups/allowed_methods 1DA,GND |
| 59 | + * @magentoConfigFixture current_store carriers/ups/free_method GND |
| 60 | + */ |
| 61 | + public function testCollectRates() |
| 62 | + { |
| 63 | + $rateRequest = Bootstrap::getObjectManager()->get(RateRequestFactory::class)->create(); |
| 64 | + $rateRequest->setDestCountryId('US'); |
| 65 | + $rateRequest->setDestRegionId('CA'); |
| 66 | + $rateRequest->setDestPostcode('90001'); |
| 67 | + $rateRequest->setPackageQty(1); |
| 68 | + $rateRequest->setPackageWeight(1); |
| 69 | + $rateRequest->setFreeMethodWeight(0); |
| 70 | + $rateRequest->setLimitCarrier($this->carrier::CODE); |
| 71 | + |
| 72 | + $rateResult = $this->carrier->collectRates($rateRequest); |
| 73 | + $result = $rateResult->asArray(); |
| 74 | + $methods = $result[$this->carrier::CODE]['methods']; |
| 75 | + $this->assertEquals(0, $methods['GND']['price']); |
| 76 | + $this->assertNotEquals(0, $methods['1DA']['price']); |
| 77 | + } |
54 | 78 | } |
0 commit comments