/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->referenceField = FieldStorageConfig::loadByName('commerce_product', 'stores');
     $display = EntityFormDisplay::load('commerce_product.default.default');
     $display->setComponent('stores', ['type' => 'commerce_entity_select', 'settings' => ['autocomplete_threshold' => 2]])->save();
     $variation = $this->createEntity('commerce_product_variation', ['type' => 'default', 'sku' => strtolower($this->randomMachineName())]);
     $this->product = $this->createEntity('commerce_product', ['type' => 'default', 'title' => $this->randomMachineName(), 'variations' => [$variation]]);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $store_type = $this->createEntity('commerce_store_type', ['id' => strtolower($this->randomMachineName(8)), 'label' => $this->randomMachineName(8)]);
     $this->stores = [];
     for ($i = 0; $i < 3; $i++) {
         $this->stores[] = $this->createEntity('commerce_store', ['type' => $store_type->id(), 'name' => $this->randomMachineName(8), 'mail' => \Drupal::currentUser()->getEmail(), 'default_currency' => 'EUR']);
     }
 }
Esempio n. 3
0
 /**
  * {@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]]);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 protected function getAdministratorPermissions()
 {
     return array_merge(['administer stores'], parent::getAdministratorPermissions());
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->type = $this->createEntity('commerce_store_type', ['id' => 'foo', 'label' => 'Label of foo']);
 }