CommerceKernelTestBase.php in Commerce Core 8.2
File
tests/src/Kernel/CommerceKernelTestBase.php
View source
<?php
namespace Drupal\Tests\commerce\Kernel;
use Drupal\commerce_price\Comparator\NumberComparator;
use Drupal\commerce_price\Comparator\PriceComparator;
use Drupal\commerce_store\StoreCreationTrait;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\Tests\commerce\Traits\DeprecationSuppressionTrait;
use SebastianBergmann\Comparator\Factory as PhpUnitComparatorFactory;
abstract class CommerceKernelTestBase extends EntityKernelTestBase {
use DeprecationSuppressionTrait;
use StoreCreationTrait;
public static $modules = [
'address',
'datetime',
'entity',
'options',
'inline_entity_form',
'views',
'commerce',
'commerce_price',
'commerce_store',
'path',
'path_alias',
];
protected $store;
protected function setUp() : void {
parent::setUp();
$this
->setErrorHandler();
$factory = PhpUnitComparatorFactory::getInstance();
$factory
->register(new NumberComparator());
$factory
->register(new PriceComparator());
$this
->installEntitySchema('path_alias');
$this
->installEntitySchema('commerce_currency');
$this
->installEntitySchema('commerce_store');
$this
->installConfig([
'commerce_store',
]);
$currency_importer = $this->container
->get('commerce_price.currency_importer');
$currency_importer
->import('USD');
$this->store = $this
->createStore('Default store', 'admin@example.com');
}
protected function tearDown() {
$this
->restoreErrorHandler();
parent::tearDown();
}
}