You are here

protected function CommerceMigrateCoreTestTrait::assertFileEntity in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/CommerceMigrateCoreTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateCoreTestTrait::assertFileEntity()
  2. 3.0.x tests/src/Kernel/CommerceMigrateCoreTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateCoreTestTrait::assertFileEntity()

Tests a single file entity.

Parameters

int $id: The file ID.

string $name: The expected file name.

string $uri: The expected URI.

string $mime: The expected MIME type.

int $size: The expected file size.

int $uid: The expected owner ID.

1 call to CommerceMigrateCoreTestTrait::assertFileEntity()
ImageTest::testFileMigration in modules/magento/tests/src/Kernel/Migrate/magento2/ImageTest.php
Tests image file migration from CSV source file.

File

tests/src/Kernel/CommerceMigrateCoreTestTrait.php, line 42

Class

CommerceMigrateCoreTestTrait
Helper function to test migrations.

Namespace

Drupal\Tests\commerce_migrate\Kernel

Code

protected function assertFileEntity($id, $name, $uri, $mime, $size, $uid) {

  /** @var \Drupal\file\FileInterface $file */
  $file = File::load($id);
  $this
    ->assertTrue($file instanceof FileInterface);
  $this
    ->assertSame($name, $file
    ->getFilename());
  $this
    ->assertSame($uri, $file
    ->getFileUri());
  $this
    ->assertTrue(file_exists($uri));
  $this
    ->assertSame($mime, $file
    ->getMimeType());
  $this
    ->assertSame($size, $file
    ->getSize());
  $this
    ->assertTrue($file
    ->isPermanent());
  $this
    ->assertSame($uid, $file
    ->getOwnerId());
}