protected function ProductBundleBrowserTestBase::setUp in Commerce Product Bundle 8
Overrides CommerceBrowserTestBase::setUp
1 call to ProductBundleBrowserTestBase::setUp()
- ProductBundleStockBrowserTestBase::setUp in modules/
commerce_product_bundle_stock/ tests/ src/ Functional/ ProductBundleStockBrowserTestBase.php
1 method overrides ProductBundleBrowserTestBase::setUp()
- ProductBundleStockBrowserTestBase::setUp in modules/
commerce_product_bundle_stock/ tests/ src/ Functional/ ProductBundleStockBrowserTestBase.php
File
- tests/
src/ Functional/ ProductBundleBrowserTestBase.php, line 84
Class
- ProductBundleBrowserTestBase
- Defines base class to use in commerce_product_bundle functional tests.
Namespace
Drupal\Tests\commerce_product_bundle\FunctionalCode
protected function setUp() {
parent::setUp();
$this->stores = [];
for ($i = 0; $i < 3; $i++) {
$this->stores[] = $this
->createStore();
}
// Create some products to test against.
for ($j = 1; $j <= 2; $j++) {
$variations = [];
for ($i = 1; $i <= 5; $i++) {
$variation = ProductVariation::create([
'type' => 'default',
'sku' => strtolower($this
->randomMachineName()),
'title' => $this
->randomString(),
'status' => $i % 2,
]);
$variation
->save();
// Not sure yet, whether we need to keep the variations.
// @todo Remove the comment or refactor.
$this->variations[] = $variation;
}
$variations = array_reverse($variations);
$product = Product::create([
'type' => 'default',
'variations' => $variations,
]);
$product
->save();
$this->products[] = $product;
}
}