LicenseDeletionTest.php in Commerce License 8.2
File
tests/src/Kernel/LicenseDeletionTest.php
View source
<?php
namespace Drupal\Tests\commerce_license\Kernel;
use Drupal\Tests\commerce_order\Kernel\OrderKernelTestBase;
class LicenseDeletionTest extends OrderKernelTestBase {
public static $modules = [
'interval',
'recurring_period',
'commerce_license',
'commerce_license_test',
];
protected $licenseStorage;
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('commerce_license');
$this->licenseStorage = \Drupal::service('entity_type.manager')
->getStorage('commerce_license');
}
public function testLicenseDeletion() {
$owner = $this
->createUser();
$license = $this->licenseStorage
->create([
'type' => 'state_change_test',
'state' => 'active',
'product_variation' => 1,
'uid' => $owner
->id(),
'expiration_type' => [
'target_plugin_id' => 'unlimited',
'target_plugin_configuration' => [],
],
]);
$license
->save();
\Drupal::state()
->set('commerce_license_state_change_test', NULL);
$license
->delete();
$this
->assertEqual(\Drupal::state()
->get('commerce_license_state_change_test'), 'revokeLicense', "The plugin's revokeLicense() method was called.");
}
}