Skip to content

Commit c5cb064

Browse files
garnett2125bojanz
authored andcommitted
Issue #2831953 by bojanz, garnett2125: Expand CommerceBrowserTestBase for stores
1 parent bde8300 commit c5cb064

17 files changed

Lines changed: 23 additions & 129 deletions

File tree

modules/checkout/tests/src/Functional/CheckoutOrderTest.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Drupal\Tests\commerce_checkout\Functional;
44

55
use Drupal\commerce_price\Price;
6-
use Drupal\commerce_store\StoreCreationTrait;
76
use Drupal\Tests\commerce\Functional\CommerceBrowserTestBase;
87
use Drupal\profile\Entity\Profile;
98
use Drupal\commerce_order\Entity\OrderItem;
@@ -18,8 +17,6 @@
1817
*/
1918
class CheckoutOrderTest extends CommerceBrowserTestBase {
2019

21-
use StoreCreationTrait;
22-
2320
/**
2421
* The current user.
2522
*
@@ -34,21 +31,14 @@ class CheckoutOrderTest extends CommerceBrowserTestBase {
3431
*/
3532
protected $product;
3633

37-
/**
38-
* The store.
39-
*
40-
* @var \Drupal\commerce_store\Entity\StoreInterface
41-
*/
42-
protected $store;
43-
4434
/**
4535
* Modules to enable.
4636
*
4737
* @var array
4838
*/
4939
public static $modules = ['system', 'field', 'user', 'text',
5040
'entity', 'views', 'address', 'profile', 'commerce', 'inline_entity_form',
51-
'commerce_price', 'commerce_store', 'commerce_product', 'commerce_cart',
41+
'commerce_price', 'commerce_product', 'commerce_cart',
5242
'commerce_checkout', 'commerce_order', 'views_ui',
5343
// @see https://www.drupal.org/node/2807567
5444
'editor',
@@ -72,8 +62,6 @@ protected function setUp() {
7262

7363
$this->placeBlock('commerce_cart');
7464

75-
$this->store = $this->createStore('Demo', 'demo@example.com', 'default', TRUE);
76-
7765
$variation = $this->createEntity('commerce_product_variation', [
7866
'type' => 'default',
7967
'sku' => strtolower($this->randomMachineName()),

modules/order/tests/src/Functional/OrderAdminTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ public function testDeleteOrder() {
158158
* Tests that an admin can view an order's details.
159159
*/
160160
public function testAdminOrderView() {
161-
$customer = $this->createUser();
162161
$order_item = $this->createEntity('commerce_order_item', [
163162
'type' => 'default',
164163
'unit_price' => [
@@ -169,12 +168,10 @@ public function testAdminOrderView() {
169168
$order = $this->createEntity('commerce_order', [
170169
'type' => 'default',
171170
'store_id' => $this->store->id(),
172-
'uid' => $customer,
173171
'mail' => $this->loggedInUser->getEmail(),
174172
'order_items' => [$order_item],
175173
'state' => 'draft',
176174
'uid' => $this->loggedInUser,
177-
'store_id' => $this->store,
178175
]);
179176

180177
// First test that the current admin user can see the order.

modules/order/tests/src/Functional/OrderBrowserTestBase.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,20 @@
22

33
namespace Drupal\Tests\commerce_order\Functional;
44

5-
use Drupal\commerce_store\StoreCreationTrait;
65
use Drupal\Tests\commerce\Functional\CommerceBrowserTestBase;
76

87
/**
98
* Defines base class for commerce_order test cases.
109
*/
1110
abstract class OrderBrowserTestBase extends CommerceBrowserTestBase {
1211

13-
use StoreCreationTrait;
14-
1512
/**
1613
* The variation to test against.
1714
*
1815
* @var \Drupal\commerce_product\Entity\ProductVariation
1916
*/
2017
protected $variation;
2118

22-
/**
23-
* The store to test against.
24-
*
25-
* @var \Drupal\commerce_store\Entity\Store
26-
*/
27-
protected $store;
28-
2919
/**
3020
* Modules to enable.
3121
*
@@ -55,9 +45,6 @@ protected function getAdministratorPermissions() {
5545
protected function setUp() {
5646
parent::setUp();
5747

58-
// Create a store.
59-
$this->store = $this->createStore();
60-
6148
// Create a product variation.
6249
$this->variation = $this->createEntity('commerce_product_variation', [
6350
'type' => 'default',

modules/order/tests/src/Functional/OrderNoStoreTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ protected function getAdministratorPermissions() {
3434
* Tests creating an order.
3535
*/
3636
public function testCreateOrder() {
37+
$this->store->delete();
3738
$this->drupalGet('admin/commerce/orders');
3839
$this->clickLink('Create a new order');
3940

modules/order/tests/src/FunctionalJavascript/OrderReassignTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Drupal\Tests\commerce_order\FunctionalJavascript;
44

55
use Drupal\commerce_order\Entity\Order;
6-
use Drupal\commerce_store\StoreCreationTrait;
76
use Drupal\Tests\commerce\Functional\CommerceBrowserTestBase;
87
use Drupal\Tests\commerce\FunctionalJavascript\JavascriptTestTrait;
98

@@ -14,16 +13,8 @@
1413
*/
1514
class OrderReassignTest extends CommerceBrowserTestBase {
1615

17-
use StoreCreationTrait;
1816
use JavascriptTestTrait;
1917

20-
/**
21-
* The store entity.
22-
*
23-
* @var \Drupal\commerce_store\Entity\Store
24-
*/
25-
protected $store;
26-
2718
/**
2819
* Modules to enable.
2920
*
@@ -50,7 +41,6 @@ protected function getAdministratorPermissions() {
5041
*/
5142
protected function setUp() {
5243
parent::setUp();
53-
$this->store = $this->createStore();
5444
}
5545

5646
/**

modules/payment/tests/src/Functional/PaymentAdminTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Drupal\commerce_payment\Entity\Payment;
66
use Drupal\commerce_price\Price;
7-
use Drupal\commerce_store\StoreCreationTrait;
87
use Drupal\Tests\commerce\Functional\CommerceBrowserTestBase;
98

109
/**
@@ -14,8 +13,6 @@
1413
*/
1514
class PaymentAdminTest extends CommerceBrowserTestBase {
1615

17-
use StoreCreationTrait;
18-
1916
/**
2017
* An on-site payment gateway.
2118
*
@@ -44,13 +41,6 @@ class PaymentAdminTest extends CommerceBrowserTestBase {
4441
*/
4542
protected $order;
4643

47-
/**
48-
* The store entity.
49-
*
50-
* @var \Drupal\commerce_store\Entity\Store
51-
*/
52-
protected $store;
53-
5444
/**
5545
* {@inheritdoc}
5646
*/
@@ -78,8 +68,6 @@ protected function getAdministratorPermissions() {
7868
protected function setUp() {
7969
parent::setUp();
8070

81-
$this->store = $this->createStore();
82-
8371
$this->paymentGateway = $this->createEntity('commerce_payment_gateway', [
8472
'id' => 'example',
8573
'label' => 'Example',

modules/payment/tests/src/Functional/PaymentCheckoutOffsiteRedirectTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Drupal\commerce_order\Entity\Order;
66
use Drupal\commerce_payment\Entity\Payment;
77
use Drupal\commerce_payment\Entity\PaymentGateway;
8-
use Drupal\commerce_store\StoreCreationTrait;
98
use Drupal\Core\Entity\Entity\EntityFormDisplay;
109
use Drupal\Tests\commerce\Functional\CommerceBrowserTestBase;
1110

@@ -16,8 +15,6 @@
1615
*/
1716
class PaymentCheckoutOffsiteRedirectTest extends CommerceBrowserTestBase {
1817

19-
use StoreCreationTrait;
20-
2118
/**
2219
* The current user.
2320
*
@@ -51,8 +48,6 @@ class PaymentCheckoutOffsiteRedirectTest extends CommerceBrowserTestBase {
5148
protected function setUp() {
5249
parent::setUp();
5350

54-
$store = $this->createStore('Demo', 'demo@example.com', 'default', TRUE);
55-
5651
$variation = $this->createEntity('commerce_product_variation', [
5752
'type' => 'default',
5853
'sku' => strtolower($this->randomMachineName()),
@@ -67,7 +62,7 @@ protected function setUp() {
6762
'type' => 'default',
6863
'title' => 'My product',
6964
'variations' => [$variation],
70-
'stores' => [$store],
65+
'stores' => [$this->store],
7166
]);
7267

7368
/** @var \Drupal\commerce_payment\Entity\PaymentGateway $gateway */

modules/payment/tests/src/Functional/PaymentCheckoutTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Drupal\commerce_order\Entity\Order;
77
use Drupal\commerce_payment\Entity\Payment;
88
use Drupal\commerce_payment\Entity\PaymentGateway;
9-
use Drupal\commerce_store\StoreCreationTrait;
109
use Drupal\Core\Entity\Entity\EntityFormDisplay;
1110
use Drupal\Tests\commerce\Functional\CommerceBrowserTestBase;
1211

@@ -17,8 +16,6 @@
1716
*/
1817
class PaymentCheckoutTest extends CommerceBrowserTestBase {
1918

20-
use StoreCreationTrait;
21-
2219
/**
2320
* The current user.
2421
*
@@ -52,8 +49,6 @@ class PaymentCheckoutTest extends CommerceBrowserTestBase {
5249
protected function setUp() {
5350
parent::setUp();
5451

55-
$store = $this->createStore('Demo', 'demo@example.com', 'default', TRUE);
56-
5752
$variation = $this->createEntity('commerce_product_variation', [
5853
'type' => 'default',
5954
'sku' => strtolower($this->randomMachineName()),
@@ -68,7 +63,7 @@ protected function setUp() {
6863
'type' => 'default',
6964
'title' => 'My product',
7065
'variations' => [$variation],
71-
'stores' => [$store],
66+
'stores' => [$this->store],
7267
]);
7368

7469
/** @var \Drupal\commerce_payment\Entity\PaymentGateway $gateway */

modules/product/tests/src/Functional/ProductBrowserTestBase.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Drupal\Tests\commerce_product\Functional;
44

55
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
6-
use Drupal\commerce_store\StoreCreationTrait;
76
use Drupal\Tests\commerce\Functional\CommerceBrowserTestBase;
87

98
/**
@@ -12,15 +11,13 @@
1211
abstract class ProductBrowserTestBase extends CommerceBrowserTestBase {
1312

1413
use EntityReferenceTestTrait;
15-
use StoreCreationTrait;
1614

1715
/**
1816
* Modules to enable.
1917
*
2018
* @var array
2119
*/
2220
public static $modules = [
23-
'commerce_store',
2421
'commerce_product',
2522
'commerce_order',
2623
'field_ui',
@@ -62,8 +59,8 @@ protected function getAdministratorPermissions() {
6259
protected function setUp() {
6360
parent::setUp();
6461

65-
$this->stores = [];
66-
for ($i = 0; $i < 3; $i++) {
62+
$this->stores = [$this->store];
63+
for ($i = 0; $i < 2; $i++) {
6764
$this->stores[] = $this->createStore();
6865
}
6966
}

modules/product/tests/src/Functional/ProductNoStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class ProductNoStoreTest extends CommerceBrowserTestBase {
1616
* {@inheritdoc}
1717
*/
1818
public static $modules = [
19-
'commerce_store',
2019
'commerce_product',
2120
];
2221

@@ -35,6 +34,7 @@ protected function getAdministratorPermissions() {
3534
* Tests creating a product.
3635
*/
3736
public function testCreateProduct() {
37+
$this->store->delete();
3838
$this->drupalGet('admin/commerce/products');
3939
$this->clickLink('Add product');
4040

0 commit comments

Comments
 (0)