Skip to content

Commit a8c5504

Browse files
committed
Improved tests coverage
1 parent 65ff06b commit a8c5504

File tree

5 files changed

+97
-1
lines changed

5 files changed

+97
-1
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/SetShippingMethodsOnCartTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected function setUp()
5555
* Test for general routine of setting a shipping method on shopping cart
5656
*
5757
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
58+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
5859
*/
5960
public function testSetShippingMethodOnCart()
6061
{
@@ -87,6 +88,7 @@ public function testSetShippingMethodOnCart()
8788

8889
/**
8990
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
91+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
9092
*/
9193
public function testSetFlatrateOnCart()
9294
{
@@ -100,19 +102,22 @@ public function testSetFlatrateOnCart()
100102

101103
/**
102104
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
105+
* @magentoApiDataFixture Magento/OfflineShipping/_files/tablerates_weight.php
106+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
103107
*/
104108
public function testSetTableRatesOnCart()
105109
{
106110
$this->setShippingMethodAndCheckResponse(
107111
'tablerate',
108112
'bestway',
109-
'15',
113+
'10',
110114
'Best Way - Table Rate'
111115
);
112116
}
113117

114118
/**
115119
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
120+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
116121
*/
117122
public function testSetFreeShippingOnCart()
118123
{
@@ -126,6 +131,21 @@ public function testSetFreeShippingOnCart()
126131

127132
/**
128133
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
134+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
135+
*/
136+
public function testSetUpsOnCart()
137+
{
138+
$this->setShippingMethodAndCheckResponse(
139+
'ups',
140+
'GND',
141+
'15.61',
142+
'United Parcel Service - Ground'
143+
);
144+
}
145+
146+
/**
147+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
148+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
129149
*/
130150
public function testSetShippingMethodWithWrongCartId()
131151
{
@@ -147,6 +167,7 @@ public function testSetShippingMethodWithWrongCartId()
147167

148168
/**
149169
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
170+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
150171
*/
151172
public function testSetNonExistingShippingMethod()
152173
{
@@ -174,6 +195,7 @@ public function testSetNonExistingShippingMethod()
174195

175196
/**
176197
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
198+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
177199
*/
178200
public function testSetShippingMethodWithNonExistingAddress()
179201
{
@@ -200,6 +222,7 @@ public function testSetShippingMethodWithNonExistingAddress()
200222

201223
/**
202224
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
225+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
203226
*/
204227
public function testSetShippingMethodByGuestToCustomerCart()
205228
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
use Magento\Framework\App\Config\Storage\Writer;
4+
use Magento\Framework\App\Config\Storage\WriterInterface;
5+
use Magento\TestFramework\Helper\Bootstrap;
6+
use Magento\Framework\App\Config\ScopeConfigInterface;
7+
8+
$objectManager = Bootstrap::getObjectManager();
9+
/** @var Writer $configWriter */
10+
$configWriter = $objectManager->create(WriterInterface::class);
11+
12+
$configWriter->save('carriers/flatrate/active', 1);
13+
$configWriter->save('carriers/tablerate/active', 1);
14+
$configWriter->save('carriers/freeshipping/active', 1);
15+
$configWriter->save('carriers/ups/active', 1);
16+
$configWriter->save('carriers/usps/active', 1);
17+
$configWriter->save('carriers/fedex/active', 1);
18+
$configWriter->save('carriers/dhl/active', 1);
19+
20+
$scopeConfig = $objectManager->get(ScopeConfigInterface::class);
21+
$scopeConfig->clean();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
use Magento\Framework\App\Config\Storage\Writer;
4+
use Magento\Framework\App\Config\Storage\WriterInterface;
5+
use Magento\TestFramework\Helper\Bootstrap;
6+
7+
$objectManager = Bootstrap::getObjectManager();
8+
/** @var Writer $configWriter */
9+
$configWriter = $objectManager->create(WriterInterface::class);
10+
11+
$configWriter->delete('carriers/flatrate/active');
12+
$configWriter->delete('carriers/tablerate/active');
13+
$configWriter->delete('carriers/freeshipping/active');
14+
$configWriter->delete('carriers/ups/active');
15+
$configWriter->delete('carriers/usps/active');
16+
$configWriter->delete('carriers/fedex/active');
17+
$configWriter->delete('carriers/dhl/active');
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
$resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
9+
$connection = $resource->getConnection();
10+
$resourceModel = $objectManager->create(\Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::class);
11+
$entityTable = $resourceModel->getTable('shipping_tablerate');
12+
$data =
13+
[
14+
'website_id' => 1,
15+
'dest_country_id' => 'US',
16+
'dest_region_id' => 0,
17+
'dest_zip' => '*',
18+
'condition_name' => 'package_weight',
19+
'condition_value' => 0,
20+
'price' => 10,
21+
'cost' => 0
22+
];
23+
$connection->query(
24+
"INSERT INTO {$entityTable} (`website_id`, `dest_country_id`, `dest_region_id`, `dest_zip`, `condition_name`,"
25+
. "`condition_value`, `price`, `cost`) VALUES (:website_id, :dest_country_id, :dest_region_id, :dest_zip,"
26+
. " :condition_name, :condition_value, :price, :cost);",
27+
$data
28+
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
require 'tablerates_rollback.php';

0 commit comments

Comments
 (0)