View source
<?php
namespace Drupal\Tests\commerce_product_bundle\Kernel;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Tests\commerce\Kernel\CommerceKernelTestBase;
abstract class CommerceProductBundleKernelTestBase extends CommerceKernelTestBase {
public static $modules = [
'address',
'datetime',
'entity',
'options',
'inline_entity_form',
'views',
'path',
'commerce',
'commerce_price',
'commerce_store',
'commerce_product',
'commerce_order',
'commerce_number_pattern',
'commerce_product_bundle',
'entity_reference_revisions',
'profile',
'state_machine',
];
protected $user;
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('commerce_product_variation');
$this
->installEntitySchema('commerce_product_variation_type');
$this
->installEntitySchema('commerce_product');
$this
->installEntitySchema('commerce_product_type');
$this
->installEntitySchema('commerce_product_bundle');
$this
->installEntitySchema('commerce_product_bundle_type');
$this
->installEntitySchema('commerce_product_bundle_i');
$this
->installEntitySchema('commerce_product_bundle_i_type');
$this
->installEntitySchema('profile');
$this
->installEntitySchema('commerce_order');
$this
->installEntitySchema('commerce_order_item');
$this
->installConfig([
'commerce_number_pattern',
'commerce_order',
'commerce_product',
'commerce_product_bundle',
]);
$user = $this
->createUser([], [
'view commerce_product',
]);
$this->user = $this
->reloadEntity($user);
$this
->drupalSetCurrentUser($this->user);
}
protected function createEntity($entity_type, array $values) {
$storage = \Drupal::service('entity_type.manager')
->getStorage($entity_type);
$entity = $storage
->create($values);
$status = $entity
->save();
$this
->assertEquals(SAVED_NEW, $status, new FormattableMarkup('Created %label entity %type.', [
'%label' => $entity
->getEntityType()
->getLabel(),
'%type' => $entity
->id(),
]));
$entity = $storage
->load($entity
->id());
return $entity;
}
}