/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create a store. $values = ['name' => t('Default store'), 'uid' => 1, 'mail' => \Drupal::config('system.site')->get('mail'), 'type' => 'default', 'default_currency' => 'USD', 'address' => ['country_code' => 'GB', 'locality' => 'London', 'postal_code' => 'NW1 6XE', 'address_line1' => '221B Baker Street']]; $this->store = Store::create($values); $this->store->save(); // Set as default store. \Drupal::configFactory()->getEditable('commerce_store.settings')->set('default_store', $this->store->uuid())->save(); // Create a product variation. $values = ['type' => 'default', 'sku' => $this->randomMachineName(), 'price' => ['amount' => 999, 'currency_code' => 'USD']]; $this->variation = ProductVariation::create($values); $this->variation->save(); // 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]]); }
protected function setUp() { parent::setUp(); $this->drupalPlaceBlock('local_tasks_block'); $this->drupalPlaceBlock('local_actions_block'); $this->drupalPlaceBlock('page_title_block'); $this->adminUser = $this->drupalCreateUser([ 'administer orders', 'administer order types', 'administer line item types', 'access administration pages', ]); // Create a store $values = [ 'name' => t('Default store'), 'uid' => 1, 'mail' => \Drupal::config('system.site')->get('mail'), 'type' => 'default', 'default_currency' => 'USD', 'address' => [ 'country_code' => 'GB', 'locality' => 'London', 'postal_code' => 'NW1 6XE', 'address_line1' => '221B Baker Street', ], ]; $this->store = Store::create($values); $this->store->save(); // Set as default store. \Drupal::configFactory()->getEditable('commerce_store.settings') ->set('default_store', $this->store->uuid())->save(); // Create a product variation. $values = [ 'type' => 'default', 'sku' => $this->randomMachineName(), ]; $this->variation = ProductVariation::create($values); $this->variation->save(); $this->drupalLogin($this->adminUser); }