You are here

public function LicenseFileManagerTest::testGetActiveLicenses in Commerce File 8.2

@covers ::getActiveLicenses

File

tests/src/Kernel/LicenseFileManagerTest.php, line 86

Class

LicenseFileManagerTest
Tests the license file manager.

Namespace

Drupal\Tests\commerce_file\Kernel

Code

public function testGetActiveLicenses() {
  $active_licenses = $this->licenseFileManager
    ->getActiveLicenses($this->file, $this->license
    ->getOwner());
  $this
    ->assertNotEmpty($active_licenses);
  $this
    ->assertInstanceOf(LicenseInterface::class, $active_licenses[0]);
  $this
    ->assertEquals($this->license
    ->id(), $active_licenses[0]
    ->id());
  $account = $this
    ->createUser();
  $this
    ->assertEmpty($this->licenseFileManager
    ->getActiveLicenses($this->file, $account));
  $this->license
    ->set('state', 'canceled');
  $this->license
    ->save();
  $this
    ->assertEmpty($this->licenseFileManager
    ->getActiveLicenses($this->file, $this->license
    ->getOwner()));
}