You are here

public function DownloadLoggerTest::testDownloadCountException in Commerce File 8.2

Tests that an exception is thrown when passing an invalid license.

@covers ::getDownloadCounts

File

tests/src/Kernel/DownloadLoggerTest.php, line 92

Class

DownloadLoggerTest
Tests the file download logger.

Namespace

Drupal\Tests\commerce_file\Kernel

Code

public function testDownloadCountException() {
  $license = $this
    ->prophesize(LicenseInterface::class);
  $license
    ->id()
    ->willReturn(100);
  $license
    ->getOwnerId()
    ->willReturn(2);
  $purchased_entity = $this
    ->prophesize(ProductVariationInterface::class);
  $purchased_entity
    ->hasField('commerce_file')
    ->willReturn(FALSE);
  $purchased_entity
    ->reveal();
  $license
    ->getPurchasedEntity()
    ->willReturn($purchased_entity);
  $license = $license
    ->reveal();
  $this
    ->expectException(\InvalidArgumentException::class);
  $this
    ->expectExceptionMessage('The purchased entity referenced by the given license does not reference any file.');
  $this->downloadLogger
    ->getDownloadCounts($license);
}