7
7
8
8
namespace Magento \OfflineShipping \Model ;
9
9
10
- use Magento \Framework \DataObject ;
11
- use Magento \Framework \ObjectManagerInterface ;
12
- use Magento \Quote \Model \Quote \Address \RateResult \Error ;
13
- use Magento \Quote \Model \Quote \Address \RateResult \Method ;
14
- use Magento \Shipping \Model \Rate \Result ;
15
- use Magento \Shipping \Model \Shipping ;
16
- use Magento \TestFramework \Helper \Bootstrap ;
17
-
18
10
/**
19
11
* Integration tests for offline shipping carriers.
20
12
* @magentoAppIsolation enabled
21
13
*/
22
- class CollectRatesTest extends \PHPUnit \ Framework \TestCase
14
+ class CollectRatesTest extends \Magento \ Shipping \ Model \CollectRatesTest
23
15
{
24
- /**
25
- * @var ObjectManagerInterface
26
- */
27
- private $ objectManager ;
28
-
29
- /**
30
- * @var Shipping
31
- */
32
- protected $ shipping ;
33
-
34
16
/**
35
17
* @var string
36
18
*/
@@ -41,28 +23,16 @@ class CollectRatesTest extends \PHPUnit\Framework\TestCase
41
23
*/
42
24
protected $ errorMessage = 'This shipping method is not available. To use this shipping method, please contact us. ' ;
43
25
44
- /**
45
- * @inheritdoc
46
- */
47
- protected function setUp ()
48
- {
49
- $ this ->objectManager = Bootstrap::getObjectManager ();
50
- $ this ->shipping = $ this ->objectManager ->get (Shipping::class);
51
- }
52
-
53
26
/**
54
27
* @magentoConfigFixture default_store carriers/flatrate/active 1
55
28
* @magentoConfigFixture default_store carriers/flatrate/sallowspecific 1
56
29
* @magentoConfigFixture default_store carriers/flatrate/specificcountry UK
57
30
* @magentoConfigFixture default_store carriers/flatrate/showmethod 1
58
31
*/
32
+ // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod
59
33
public function testCollectRatesWhenShippingCarrierIsAvailableAndNotApplicable ()
60
34
{
61
- $ result = $ this ->shipping ->collectRatesByAddress ($ this ->getAddress (), $ this ->carrier );
62
- $ rate = $ this ->getRate ($ result ->getResult ());
63
-
64
- static ::assertEquals ($ this ->carrier , $ rate ->getData ('carrier ' ));
65
- static ::assertEquals ($ this ->errorMessage , $ rate ->getData ('error_message ' ));
35
+ parent ::testCollectRatesWhenShippingCarrierIsAvailableAndNotApplicable ();
66
36
}
67
37
68
38
/**
@@ -71,48 +41,9 @@ public function testCollectRatesWhenShippingCarrierIsAvailableAndNotApplicable()
71
41
* @magentoConfigFixture default_store carriers/flatrate/specificcountry UK
72
42
* @magentoConfigFixture default_store carriers/flatrate/showmethod 1
73
43
*/
44
+ // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod
74
45
public function testCollectRatesWhenShippingCarrierIsNotAvailableAndNotApplicable ()
75
46
{
76
- $ result = $ this ->shipping ->collectRatesByAddress ($ this ->getAddress (), $ this ->carrier );
77
- $ rate = $ this ->getRate ($ result ->getResult ());
78
-
79
- static ::assertNull ($ rate );
80
- }
81
-
82
- /**
83
- * @return DataObject
84
- */
85
- private function getAddress (): DataObject
86
- {
87
- $ address = $ this ->objectManager ->create (
88
- DataObject::class,
89
- [
90
- 'data ' => [
91
- 'region_id ' => 'CA ' ,
92
- 'postcode ' => '11111 ' ,
93
- 'lastname ' => 'John ' ,
94
- 'firstname ' => 'Doe ' ,
95
- 'street ' => 'Some street ' ,
96
- 'city ' => 'Los Angeles ' ,
97
- 'email ' => 'john.doe@example.com ' ,
98
- 'telephone ' => '11111111 ' ,
99
- 'country_id ' => 'US ' ,
100
- 'item_qty ' => 1 ,
101
- ],
102
- ]
103
- );
104
-
105
- return $ address ;
106
- }
107
-
108
- /**
109
- * @param Result $result
110
- * @return Method|Error
111
- */
112
- private function getRate (Result $ result )
113
- {
114
- $ rates = $ result ->getAllRates ();
115
-
116
- return array_pop ($ rates );
47
+ parent ::testCollectRatesWhenShippingCarrierIsNotAvailableAndNotApplicable ();
117
48
}
118
49
}
0 commit comments