Skip to content

Commit 3ce8f20

Browse files
author
Dmytro Yushkin
committed
MAGETWO-54134: CE module depends on EE code
- Fixed unit test
1 parent 89ee3f9 commit 3ce8f20

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Usps\Test\Unit\Model;
77

88
use Magento\Quote\Model\Quote\Address\RateRequest;
9+
use Magento\Usps\Helper\Data as DataHelper;
910
use Magento\Usps\Model\Carrier;
1011

1112
/**
@@ -43,6 +44,11 @@ class CarrierTest extends \PHPUnit_Framework_TestCase
4344
*/
4445
protected $scope;
4546

47+
/**
48+
* @var DataHelper|\PHPUnit_Framework_MockObject_MockObject
49+
*/
50+
private $dataHelper;
51+
4652
/**
4753
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
4854
*/
@@ -154,7 +160,14 @@ function ($data) {
154160

155161
];
156162

163+
$this->dataHelper = $this->getMockBuilder(DataHelper::class)
164+
->disableOriginalConstructor()
165+
->setMethods(['displayGirthValue'])
166+
->getMock();
167+
157168
$this->carrier = $this->helper->getObject(\Magento\Usps\Model\Carrier::class, $arguments);
169+
170+
$this->helper->setBackwardCompatibleProperty($this->carrier, 'dataHelper', $this->dataHelper);
158171
}
159172

160173
/**
@@ -324,4 +337,33 @@ public function logDataProvider()
324337
],
325338
];
326339
}
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+
}
327369
}

0 commit comments

Comments
 (0)