You are here

protected function FileMigrationSetupTrait::assertEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/file/tests/src/Kernel/Migrate/d7/FileMigrationSetupTrait.php \Drupal\Tests\file\Kernel\Migrate\d7\FileMigrationSetupTrait::assertEntity()

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.

string $size: The expected file size.

string $created: The expected creation time.

string $changed: The expected modification time.

string $uid: The expected owner ID.

2 calls to FileMigrationSetupTrait::assertEntity()
MigrateFileTest::testFileMigration in core/modules/file/tests/src/Kernel/Migrate/d7/MigrateFileTest.php
Tests that all expected files are migrated.
MigratePrivateFileTest::testFileMigration in core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php
Tests that all expected files are migrated.
1 method overrides FileMigrationSetupTrait::assertEntity()
MigrateNodeTest::assertEntity in core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php
Asserts various aspects of a node.

File

core/modules/file/tests/src/Kernel/Migrate/d7/FileMigrationSetupTrait.php, line 65

Class

FileMigrationSetupTrait
A trait to setup the file migration.

Namespace

Drupal\Tests\file\Kernel\Migrate\d7

Code

protected function assertEntity($id, $name, $uri, $mime, $size, $created, $changed, $uid) {

  /** @var \Drupal\file\FileInterface $file */
  $file = File::load($id);
  $this
    ->assertInstanceOf(FileInterface::class, $file);
  $this
    ->assertSame($name, $file
    ->getFilename());
  $this
    ->assertSame($uri, $file
    ->getFileUri());
  $this
    ->assertFileExists($uri);
  $this
    ->assertSame($mime, $file
    ->getMimeType());
  $this
    ->assertSame($size, $file
    ->getSize());

  // isPermanent(), isTemporary(), etc. are determined by the status column.
  $this
    ->assertTrue($file
    ->isPermanent());
  $this
    ->assertSame($created, $file
    ->getCreatedTime());
  $this
    ->assertSame($changed, $file
    ->getChangedTime());
  $this
    ->assertSame($uid, $file
    ->getOwnerId());
}