MigrateIngredient61Test.php in Recipe 8.2
File
modules/ingredient/tests/src/Kernel/Migrate/recipe61/MigrateIngredient61Test.php
View source
<?php
namespace Drupal\Tests\ingredient\Kernel\Migrate\recipe61;
use Drupal\Core\Database\Database;
use Drupal\ingredient\Entity\Ingredient;
use Drupal\ingredient\IngredientInterface;
class MigrateIngredient61Test extends MigrateIngredient61TestBase {
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);
}
}
}