public function MigrateRecipe71Test::testRecipeFields in Recipe 8.2
Tests the migration of Recipe 7.x fields except for the yield fields.
The yield fields are handled by a separate migration which is tested by another class.
File
- tests/
src/ Kernel/ Migrate/ recipe71/ MigrateRecipe71Test.php, line 87
Class
- MigrateRecipe71Test
- @covers \Drupal\recipe\Plugin\migrate\source\recipe71\ @group recipe
Namespace
Drupal\Tests\recipe\Kernel\Migrate\recipe71Code
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.
$source->ingredients = $database_connection
->select('recipe_node_ingredient', 'rni')
->fields('rni')
->condition('rni.nid', $source->nid)
->execute()
->fetchAll();
}
$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));
}