You are here

public function S3FileMapTest::testRecordDataValidity in Acquia Content Hub 8.2

@covers ::record

File

modules/acquia_contenthub_s3/tests/src/Kernel/S3FileMapTest.php, line 58

Class

S3FileMapTest
Tests the S3FileMap.

Namespace

Drupal\Tests\acquia_contenthub_s3\Kernel

Code

public function testRecordDataValidity() {
  $valid = [
    'd2ded609-c7eb-4ca0-97cc-5bb0ddbbbf5a',
    'custom-bucket',
    'custom-root-folder',
    'd2ded609-c7eb-4ca0-97cc-5bb0ddbbbf55',
  ];
  $records = $this
    ->fetchAllData();
  $this
    ->assertCount(0, $records, 'Table is empty.');
  $this->s3FileMap
    ->record(...$valid);
  $records = $this
    ->fetchAllData();
  $this
    ->assertCount(1, $records, 'File was successfully recorded.');
  $invalid_uuid = [
    'd2ded609-c7eb-4ca0-97cc-5bb0ddbbbf5',
    'custom-bucket',
    'custom-root-folder',
    'd2ded609-c7eb-4ca0-97cc-5bb0ddbbbf55',
  ];
  $this
    ->expectException(\Exception::class);
  $this->s3FileMap
    ->record(...$invalid_uuid);
  $invalid_uuid = [
    'd2ded609-c7eb-4ca0-97cc-5bb0ddbbbf55',
    'custom-bucket',
    'custom-root-folder',
    'invalid',
  ];
  $this
    ->expectException(\InvalidArgumentException::class);
  $this->s3FileMap
    ->record(...$invalid_uuid);
}