|
6 | 6 | namespace Magento\Usps\Test\Unit\Model;
|
7 | 7 |
|
8 | 8 | use Magento\Quote\Model\Quote\Address\RateRequest;
|
| 9 | +use Magento\Usps\Helper\Data as DataHelper; |
9 | 10 | use Magento\Usps\Model\Carrier;
|
10 | 11 |
|
11 | 12 | /**
|
@@ -43,6 +44,11 @@ class CarrierTest extends \PHPUnit_Framework_TestCase
|
43 | 44 | */
|
44 | 45 | protected $scope;
|
45 | 46 |
|
| 47 | + /** |
| 48 | + * @var DataHelper|\PHPUnit_Framework_MockObject_MockObject |
| 49 | + */ |
| 50 | + private $dataHelper; |
| 51 | + |
46 | 52 | /**
|
47 | 53 | * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
48 | 54 | */
|
@@ -154,7 +160,14 @@ function ($data) {
|
154 | 160 |
|
155 | 161 | ];
|
156 | 162 |
|
| 163 | + $this->dataHelper = $this->getMockBuilder(DataHelper::class) |
| 164 | + ->disableOriginalConstructor() |
| 165 | + ->setMethods(['displayGirthValue']) |
| 166 | + ->getMock(); |
| 167 | + |
157 | 168 | $this->carrier = $this->helper->getObject(\Magento\Usps\Model\Carrier::class, $arguments);
|
| 169 | + |
| 170 | + $this->helper->setBackwardCompatibleProperty($this->carrier, 'dataHelper', $this->dataHelper); |
158 | 171 | }
|
159 | 172 |
|
160 | 173 | /**
|
@@ -324,4 +337,33 @@ public function logDataProvider()
|
324 | 337 | ],
|
325 | 338 | ];
|
326 | 339 | }
|
| 340 | + |
| 341 | + /** |
| 342 | + * @param string $countyCode |
| 343 | + * @param string $carrierMethodCode |
| 344 | + * @param bool $displayGirthValueResult |
| 345 | + * @param bool $result |
| 346 | + * @dataProvider isGirthAllowedDataProvider |
| 347 | + */ |
| 348 | + public function testIsGirthAllowed($countyCode, $carrierMethodCode, $displayGirthValueResult, $result) |
| 349 | + { |
| 350 | + $this->dataHelper->expects(static::any()) |
| 351 | + ->method('displayGirthValue') |
| 352 | + ->with($carrierMethodCode) |
| 353 | + ->willReturn($displayGirthValueResult); |
| 354 | + |
| 355 | + self::assertEquals($result, $this->carrier->isGirthAllowed($countyCode, $carrierMethodCode)); |
| 356 | + } |
| 357 | + |
| 358 | + /** |
| 359 | + * @return array |
| 360 | + */ |
| 361 | + public function isGirthAllowedDataProvider() |
| 362 | + { |
| 363 | + return [ |
| 364 | + ['US', 'usps_1', true, false], |
| 365 | + ['UK', 'usps_1', true, true], |
| 366 | + ['US', 'usps_0', false, true], |
| 367 | + ]; |
| 368 | + } |
327 | 369 | }
|
0 commit comments