
| Current Path : /var/www/html/store/web/modules/contrib/commerce/tests/src/Kernel/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/store/web/modules/contrib/commerce/tests/src/Kernel/CommerceKernelTestBase.php |
<?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\Core\StringTranslation\StringTranslationTrait;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\Tests\commerce\Traits\DeprecationSuppressionTrait;
use SebastianBergmann\Comparator\Factory as PhpUnitComparatorFactory;
/**
* Provides a base class for Commerce kernel tests.
*/
abstract class CommerceKernelTestBase extends EntityKernelTestBase {
use DeprecationSuppressionTrait;
use StoreCreationTrait;
use StringTranslationTrait;
/**
* Modules to enable.
*
* Note that when a child class declares its own $modules list, that list
* doesn't override this one, it just extends it.
*
* @var array
*/
protected static $modules = [
'address',
'datetime',
'entity',
'options',
'inline_entity_form',
'views',
'commerce',
'commerce_price',
'commerce_store',
'path',
'path_alias',
];
/**
* The default store.
*
* @var \Drupal\commerce_store\Entity\StoreInterface
*/
protected $store;
/**
* {@inheritdoc}
*/
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');
}
/**
* {@inheritdoc}
*/
protected function tearDown(): void {
$this->restoreErrorHandler();
parent::tearDown();
}
}