public function MigrateRecipe61Test::testRecipeFields in Recipe 8.2
Tests the Drupal 6 recipe to Drupal 8 migration.
File
- tests/
src/ Kernel/ Migrate/ recipe61/ MigrateRecipe61Test.php, line 89
Class
- MigrateRecipe61Test
- @covers \Drupal\recipe\Plugin\migrate\source\recipe61\Recipe61 @group recipe
Namespace
Drupal\Tests\recipe\Kernel\Migrate\recipe61Code
public function testRecipeFields() {
$database_connection = Database::getConnection('default', 'migrate');
$recipes = $database_connection
->select('recipe', 'r')
->fields('r')
->execute()
->fetchAll();
foreach ($recipes as &$source) {
// Get a list of ingredient IDs from the old database.
$query = $database_connection
->select('recipe_node_ingredient', 'i');
$query
->leftJoin('recipe_unit', 'ru', 'i.unit_id = ru.id');
$query
->fields('i', [
'quantity',
'ingredient_id',
'weight',
'note',
])
->fields('ru', [
'name',
])
->condition('i.nid', $source->nid);
$results = $query
->execute()
->fetchAll();
$source->ingredients = $this
->addUnitKeys($results);
}
$node = Node::load(1);
$this
->assertRecipeFields($node, array_shift($recipes));
// Verify the fields of an English-language recipe.
$node = Node::load(2);
$this
->assertRecipeFields($node, array_shift($recipes));
$this
->assertTrue($node
->hasTranslation('is'), 'Node 2 has an Islandic translation');
// Verify the fields of a Islandic-language recipe that was translated from
// node 2.
$translation = $node
->getTranslation('is');
$this
->assertRecipeFields($translation, array_shift($recipes));
}