|
7 | 7 |
|
8 | 8 | use Magento\Quote\Model\Quote\Address\RateRequest;
|
9 | 9 | use Magento\Ups\Model\Carrier;
|
| 10 | +use Magento\Directory\Model\Country; |
| 11 | +use PHPUnit_Framework_MockObject_MockObject as MockObject; |
10 | 12 |
|
11 | 13 | /**
|
12 | 14 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
@@ -57,7 +59,7 @@ class CarrierTest extends \PHPUnit_Framework_TestCase
|
57 | 59 | protected $countryFactory;
|
58 | 60 |
|
59 | 61 | /**
|
60 |
| - * @var \Magento\Directory\Model\Country |
| 62 | + * @var Country|MockObject |
61 | 63 | */
|
62 | 64 | protected $country;
|
63 | 65 |
|
@@ -309,4 +311,47 @@ public function logDataProvider()
|
309 | 311 | ]
|
310 | 312 | ];
|
311 | 313 | }
|
| 314 | + |
| 315 | + /** |
| 316 | + * @covers \Magento\Ups\Model\Carrier::setRequest |
| 317 | + * @param string $countryCode |
| 318 | + * @param string $foundCountryCode |
| 319 | + * @dataProvider countryDataProvider |
| 320 | + */ |
| 321 | + public function testSetRequest($countryCode, $foundCountryCode) |
| 322 | + { |
| 323 | + /** @var RateRequest $request */ |
| 324 | + $request = $this->helper->getObject(RateRequest::class); |
| 325 | + $request->setData([ |
| 326 | + 'orig_country' => 'USA', |
| 327 | + 'orig_region_code' => 'CA', |
| 328 | + 'orig_post_code' => 90230, |
| 329 | + 'orig_city' => 'Culver City', |
| 330 | + 'dest_country_id' => $countryCode, |
| 331 | + ]); |
| 332 | + |
| 333 | + $this->country->expects(static::at(1)) |
| 334 | + ->method('load') |
| 335 | + ->with($countryCode) |
| 336 | + ->willReturnSelf(); |
| 337 | + |
| 338 | + $this->country->expects(static::any()) |
| 339 | + ->method('getData') |
| 340 | + ->with('iso2_code') |
| 341 | + ->willReturn($foundCountryCode); |
| 342 | + |
| 343 | + $this->model->setRequest($request); |
| 344 | + } |
| 345 | + |
| 346 | + /** |
| 347 | + * Get list of country variations |
| 348 | + * @return array |
| 349 | + */ |
| 350 | + public function countryDataProvider() |
| 351 | + { |
| 352 | + return [ |
| 353 | + ['countryCode' => 'PR', 'foundCountryCode' => null], |
| 354 | + ['countryCode' => 'US', 'foundCountryCode' => 'US'], |
| 355 | + ]; |
| 356 | + } |
312 | 357 | }
|
0 commit comments