protected function MediaMigrationAssertionsForMediaSourceTrait::assertMedia1FieldValues in Media Migration 8
Assertions of media 1.
Assert "Blue PNG" image media properties; including alt, title and the custom 'integer' field.
6 calls to MediaMigrationAssertionsForMediaSourceTrait::assertMedia1FieldValues()
- DrushWithCoreMigrationsFromMediaTest::testAllMigrationWithDrush in tests/
src/ Functional/ DrushWithCoreMigrationsFromMediaTest.php - Test all migrations with Drush and Migrate Tools.
- DrushWithCoreMigrationsFromMediaTest::testMigrationWithDrush in tests/
src/ Functional/ DrushWithCoreMigrationsFromMediaTest.php - Test media migrations with Drush and Migrate Tools.
- DrushWithMigrateUpgradeFromMediaTest::testMigrationWithDrush in tests/
src/ Functional/ DrushWithMigrateUpgradeFromMediaTest.php - Tests migrations with Migrate Upgrade, Drush and Migrate Tools.
- MediaMigrationTest::testChangeTracking in tests/
src/ Kernel/ Migrate/ MediaMigrationTest.php - Tests media entity migration with change tracking enabled.
- MediaMigrationTest::testMediaMigration in tests/
src/ Kernel/ Migrate/ MediaMigrationTest.php - Tests the migration of media entities.
File
- tests/
src/ Traits/ MediaMigrationAssertionsForMediaSourceTrait.php, line 24
Class
- MediaMigrationAssertionsForMediaSourceTrait
- Trait for media migration tests.
Namespace
Drupal\Tests\media_migration\TraitsCode
protected function assertMedia1FieldValues($name = 'Blue PNG') {
$media1 = $this->container
->get('entity_type.manager')
->getStorage('media')
->load(1);
$this
->assertInstanceOf(MediaInterface::class, $media1);
$this
->assertEquals($name, $media1
->label());
$this
->assertEquals('image', $media1
->bundle());
// Check 'field media image' field.
$media1_image = $this
->getReferencedEntities($media1, 'field_media_image', 1);
assert($media1_image[0] instanceof FileInterface);
$this
->assertEquals('1', $media1_image[0]
->id());
$this
->assertEquals('1', $media1->field_media_image->target_id);
// Alt and title properties should be migrated to the corresponding media
// image field and have to be editable on the UI.
$this
->assertEquals('Alternative text about blue.png', $media1->field_media_image->alt);
$this
->assertEquals('Title copy for blue.png', $media1->field_media_image->title);
$this
->assertEquals('1000', $media1->field_media_integer->value);
// The following fields should not be present.
$this
->assertFalse($media1
->hasField('field_file_image_alt_text'));
$this
->assertFalse($media1
->hasField('field_file_image_title_text'));
// Author should be user 1.
$this
->assertEquals('1', $media1
->getOwnerId());
// Assert authored on date.
$this
->assertEquals('1587725909', $media1
->getCreatedTime());
// The image file should exist.
$this
->assertTrue(file_exists($media1_image[0]
->getFileUri()));
}