protected function MigrateRecipe61Test::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.
- $recipe->yield: A measure of how much this recipe will produce.
- $recipe->yield_unit: The unit that $yield is expressed in.
1 call to MigrateRecipe61Test::assertRecipeFields()
- MigrateRecipe61Test::testRecipeFields in tests/
src/ Kernel/ Migrate/ recipe61/ MigrateRecipe61Test.php - Tests the Drupal 6 recipe to Drupal 8 migration.
File
- tests/
src/ Kernel/ Migrate/ recipe61/ MigrateRecipe61Test.php, line 70
Class
- MigrateRecipe61Test
- @covers \Drupal\recipe\Plugin\migrate\source\recipe61\Recipe61 @group recipe
Namespace
Drupal\Tests\recipe\Kernel\Migrate\recipe61Code
protected function assertRecipeFields(NodeInterface $node, \stdClass $recipe) {
$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);
$this
->assertEquals($recipe->yield, $node->recipe_yield_amount->value);
$this
->assertSame($recipe->yield_unit, $node->recipe_yield_unit->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);
}
}