diff --git a/tests/src/Functional/VadoDiscountsTest.php b/tests/src/Functional/VadoDiscountsTest.php index a725133..76e1552 100644 --- a/tests/src/Functional/VadoDiscountsTest.php +++ b/tests/src/Functional/VadoDiscountsTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\commerce_vado\Functional; use Drupal\Core\Entity\Entity\EntityViewDisplay; use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Tests\commerce_cart\Functional\CartBrowserTestBase; +use Drupal\Tests\commerce_vado\Traits\VadoCreationTrait; /** * Tests commerce_vado bundle discount field. @@ -13,6 +14,8 @@ use Drupal\Tests\commerce_cart\Functional\CartBrowserTestBase; */ class VadoDiscountsTest extends CartBrowserTestBase { + use VadoCreationTrait; + /** * The order storage. * @@ -79,102 +82,60 @@ class VadoDiscountsTest extends CartBrowserTestBase { $variation_view_display->save(); /** @var \Drupal\commerce_product\Entity\Product $parent_product */ - $this->parent_product = $this->createEntity('commerce_product', [ - 'type' => 'default', + $this->parent_product = $this->createProductWithVariations(1, [ 'title' => 'Parent Product', - 'stores' => [$this->store], - 'body' => ['value' => 'This is a parent product'], 'variations' => [ - $this->createEntity('commerce_product_variation', [ - 'type' => 'default', + [ 'sku' => 'PARENT', - 'price' => [ - 'number' => '100.00', - 'currency_code' => 'USD', - ], - ]), + 'price' => ['number' => '100.00'], + ], ], ]); /** @var \Drupal\commerce_product\Entity\Product $child_product */ - $this->child_product = $this->createEntity('commerce_product', [ - 'type' => 'default', + $this->child_product = $this->createProductWithVariations(1, [ 'title' => 'Child Product', - 'stores' => [$this->store], - 'body' => ['value' => 'This is a child product'], 'variations' => [ - $this->createEntity('commerce_product_variation', [ + [ 'title' => 'Child Product 1', - 'type' => 'default', 'sku' => 'CHILD', - 'price' => [ - 'number' => '75.99', - 'currency_code' => 'USD', - ], - ]), + 'price' => ['number' => '75.99'], + ], ], ]); - $this->child_product_1 = $this->createEntity('commerce_product', [ - 'type' => 'default', + $this->child_product_1 = $this->createProductWithVariations(1, [ 'title' => 'Child Product 1', - 'stores' => [$this->store], - 'body' => ['value' => 'This is child product 1'], 'variations' => [ - $this->createEntity('commerce_product_variation', [ - 'type' => 'default', + [ 'sku' => 'CHILD-1', - 'price' => [ - 'number' => '110.00', - 'currency_code' => 'USD', - ], - ]), + 'price' => ['number' => '110.00'], + ], ], ]); - $this->child_product_2 = $this->createEntity('commerce_product', [ - 'type' => 'default', + $this->child_product_2 = $this->createProductWithVariations(1, [ 'title' => 'Child Product 2', - 'stores' => [$this->store], - 'body' => ['value' => 'This is child product 2'], 'variations' => [ - $this->createEntity('commerce_product_variation', [ - 'type' => 'default', + [ 'sku' => 'CHILD-2', - 'price' => [ - 'number' => '210.00', - 'currency_code' => 'USD', - ], - ]), + 'price' => ['number' => '210.00'], + ], ], ]); - $this->child_product_3 = $this->createEntity('commerce_product', [ - 'type' => 'default', + $this->child_product_3 = $this->createProductWithVariations(1, [ 'title' => 'Child Product 3', - 'stores' => [$this->store], - 'body' => ['value' => 'This is child product 3'], 'variations' => [ - $this->createEntity('commerce_product_variation', [ - 'type' => 'default', + [ 'sku' => 'CHILD-3', - 'price' => [ - 'number' => '310.00', - 'currency_code' => 'USD', - ], - ]), + 'price' => ['number' => '310.00'], + ], ], ]); - $this->child_product_4 = $this->createEntity('commerce_product', [ - 'type' => 'default', + $this->child_product_4 = $this->createProductWithVariations(1, [ 'title' => 'Child Product 4', - 'stores' => [$this->store], - 'body' => ['value' => 'This is child product 4'], 'variations' => [ - $this->createEntity('commerce_product_variation', [ - 'type' => 'default', + [ 'sku' => 'CHILD-4', - 'price' => [ - 'number' => '410.00', - 'currency_code' => 'USD', - ], - ]), + 'price' => ['number' => '410.00'], + ], ], ]); /** @var \Drupal\commerce_product\Entity\ProductVariation $this->parent_variation */