You are here

public function S3FileMapperTest::testMapS3FileNoBucket in Acquia Content Hub 8.2

@covers ::mapS3File @dataProvider mapS3FileDataProvider

Parameters

string|null $bucket: The bucket attribute.

string|null $source: The source attribute.

Throws

\Drupal\Core\Entity\EntityStorageException

File

modules/acquia_contenthub_s3/tests/src/Kernel/S3FileMapperTest.php, line 78

Class

S3FileMapperTest
Tests the S3FileMapper.

Namespace

Drupal\Tests\acquia_contenthub_s3\Kernel

Code

public function testMapS3FileNoBucket(?string $bucket, ?string $source) {
  $file = $this
    ->createFileEntity('test.png', 's3');
  $cdf = $this
    ->prophesize(CDFObject::class);
  $cdf
    ->getAttribute(Argument::is('ach_s3_bucket'))
    ->willReturn($this
    ->createCdfAttribute($bucket));
  $cdf
    ->getAttribute(Argument::is('ach_s3_source'))
    ->willReturn($this
    ->createCdfAttribute($source));
  $map = $this
    ->prophesize(S3FileMap::class);
  $map
    ->record(Argument::any())
    ->shouldNotBeCalled();
  $this->container
    ->set('acquia_contenthub_s3.file_map', $map
    ->reveal());
  $mapper = $this
    ->constructFileMapper();
  $mapper
    ->mapS3File($cdf
    ->reveal(), $file);
  $s3_file = $this->container
    ->get('database')
    ->select(S3FileMap::TABLE_NAME, 'acs3')
    ->fields('acs3')
    ->condition('file_uuid', $file
    ->uuid(), '=')
    ->execute()
    ->fetchObject();
  $this
    ->assertFalse($s3_file);
}