protected function MigrateRecipe71Test::assertRecipeFields in Recipe 8.2
Asserts various aspects of a recipe.
Parameters
\Drupal\node\NodeInterface $node: The imported recipe node.
\stdClass $recipe: A stdClass object with the following properties:
- $recipe->description: A short description of the recipe.
- $recipe->ingredients: An array of ingredients for the recipe.
- $recipe->instructions: Instructions on how to prepare the recipe.
- $recipe->notes: Other notes about this recipe.
- $recipe->preptime: The preparation time in minutes.
- $recipe->source: Who deserves credit for this recipe.
1 call to MigrateRecipe71Test::assertRecipeFields()
- MigrateRecipe71Test::testRecipeFields in tests/
src/ Kernel/ Migrate/ recipe71/ MigrateRecipe71Test.php - Tests the migration of Recipe 7.x fields except for the yield fields.
File
- tests/
src/ Kernel/ Migrate/ recipe71/ MigrateRecipe71Test.php, line 65
Class
- MigrateRecipe71Test
- @covers \Drupal\recipe\Plugin\migrate\source\recipe71\ @group recipe
Namespace
Drupal\Tests\recipe\Kernel\Migrate\recipe71Code
protected function assertRecipeFields(NodeInterface $node, \stdClass $recipe) {
$this
->assertEquals($recipe->cooktime, $node->recipe_cook_time->value);
$this
->assertSame($recipe->description, $node->recipe_description->value);
$this
->assertSame($recipe->instructions, $node->recipe_instructions->value);
$this
->assertSame($recipe->notes, $node->recipe_notes->value);
$this
->assertEquals($recipe->preptime, $node->recipe_prep_time->value);
$this
->assertSame($recipe->source, $node->recipe_source->value);
for ($i = 0; $i < count($recipe->ingredients); $i++) {
$this
->assertEquals($recipe->ingredients[$i]->quantity, $node->recipe_ingredient[$i]->quantity);
$this
->assertEquals($recipe->ingredients[$i]->unit_key, $node->recipe_ingredient[$i]->unit_key);
$this
->assertEquals($recipe->ingredients[$i]->ingredient_id, $node->recipe_ingredient[$i]->target_id);
$this
->assertEquals($recipe->ingredients[$i]->note, $node->recipe_ingredient[$i]->note);
}
}