public function CartResourceTestBase::setUp in Commerce Cart API 8
Overrides ResourceTestBase::setUp
10 calls to CartResourceTestBase::setUp()
- CartAccessApiResourceTest::setUp in tests/
src/ Functional/ CartAccessApiResourceTest.php - CartAddResourceTest::setUp in tests/
src/ Functional/ CartAddResourceTest.php - CartCanonicalResourceTest::setUp in tests/
src/ Functional/ CartCanonicalResourceTest.php - CartClearResourceTest::setUp in tests/
src/ Functional/ CartClearResourceTest.php - CartCollectionResourceTest::setUp in tests/
src/ Functional/ CartCollectionResourceTest.php
10 methods override CartResourceTestBase::setUp()
- CartAccessApiResourceTest::setUp in tests/
src/ Functional/ CartAccessApiResourceTest.php - CartAddResourceTest::setUp in tests/
src/ Functional/ CartAddResourceTest.php - CartCanonicalResourceTest::setUp in tests/
src/ Functional/ CartCanonicalResourceTest.php - CartClearResourceTest::setUp in tests/
src/ Functional/ CartClearResourceTest.php - CartCollectionResourceTest::setUp in tests/
src/ Functional/ CartCollectionResourceTest.php
File
- tests/
src/ Functional/ CartResourceTestBase.php, line 78
Class
- CartResourceTestBase
- Defines base class for commerce_cart_api test cases.
Namespace
Drupal\Tests\commerce_cart_api\FunctionalCode
public function setUp() {
parent::setUp();
$this->store = $this
->createStore();
$this->cartManager = \Drupal::service('commerce_cart.cart_manager');
$this->cartProvider = \Drupal::service('commerce_cart.cart_provider');
// Create a product variation.
$this->variation = $this
->createEntity('commerce_product_variation', [
'type' => 'default',
'sku' => $this
->randomMachineName(),
'price' => [
'number' => 1000,
'currency_code' => 'USD',
],
]);
// Create a second product variation.
$this->variation_2 = $this
->createEntity('commerce_product_variation', [
'type' => 'default',
'sku' => $this
->randomMachineName(),
'price' => [
'number' => 500,
'currency_code' => 'USD',
],
]);
// We need a product too otherwise tests complain about the missing
// backreference.
$this
->createEntity('commerce_product', [
'type' => 'default',
'title' => $this
->randomMachineName(),
'stores' => [
$this->store,
],
'variations' => [
$this->variation,
$this->variation_2,
],
]);
$auth = isset(static::$auth) ? [
static::$auth,
] : [];
$this
->provisionResource([
static::$format,
], $auth);
$this
->initAuthentication();
}