You are here

public function S3FileMapTest::testGetFileByUri in Acquia Content Hub 8.2

@covers ::getFileByUri

File

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

Class

S3FileMapTest
Tests the S3FileMap.

Namespace

Drupal\Tests\acquia_contenthub_s3\Kernel

Code

public function testGetFileByUri() {
  $file = $this
    ->createFileEntity('thelocation/test.jpg', 's3');
  $this->s3FileMap
    ->record($file
    ->uuid(), 'bucket', 'root_folder', '23623525-fb2f-4035-b5ca-a6d64e212ed9');
  $object = $this->s3FileMap
    ->getFileByUri($file
    ->getFileUri());
  $this
    ->assertInstanceOf('stdClass', $object, 'Returned data is of type stdClass.');
  $this
    ->assertEqual($object->uuid, $file
    ->uuid(), 'File uuid match.');
  $this
    ->assertEqual($object->bucket, 'bucket', 'Bucket match.');
  $this
    ->assertEqual($object->root_folder, 'root_folder', 'Root folder match.');
  $this
    ->assertEqual($object->origin_uuid, '23623525-fb2f-4035-b5ca-a6d64e212ed9', 'Origin uuid match.');
  $object = $this->s3FileMap
    ->getFileByUri('s3://non-existent-file.jpg');
  $this
    ->assertNull($object, 'Non existent file, return value is NULL.');
}