MigrateIngredient71Test.php in Recipe 8.2
File
modules/ingredient/tests/src/Kernel/Migrate/recipe71/MigrateIngredient71Test.php
View source
<?php
namespace Drupal\Tests\ingredient\Kernel\Migrate\recipe71;
use Drupal\Core\Database\Database;
use Drupal\ingredient\Entity\Ingredient;
use Drupal\ingredient\IngredientInterface;
class MigrateIngredient71Test extends MigrateIngredient71TestBase {
protected static $modules = [
'ingredient',
];
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('ingredient');
$this
->executeMigrations([
'recipe1x_ingredient',
]);
}
protected function assertEntity($id, $label) {
$ingredient = Ingredient::load($id);
$this
->assertTrue($ingredient instanceof IngredientInterface);
$this
->assertSame($label, $ingredient
->label());
}
public function testIngredient() {
$ingredients = Database::getConnection('default', 'migrate')
->select('recipe_ingredient', 'i')
->fields('i')
->execute()
->fetchAll();
foreach ($ingredients as $source) {
$this
->assertEntity($source->id, $source->name);
}
}
}