public function MigrateIngredient72Test::testRecipeFields in Recipe 8.2
@covers ::alterFieldInstanceMigration @covers ::alterFieldFormatterMigration @covers ::defineValueProcessPipeline
File
- modules/
ingredient/ tests/ src/ Kernel/ Migrate/ recipe72/ MigrateIngredient72Test.php, line 62
Class
- MigrateIngredient72Test
- @coversDefaultClass \Drupal\ingredient\Plugin\migrate\field\IngredientReference @group ingredient
Namespace
Drupal\Tests\ingredient\Kernel\Migrate\recipe72Code
public function testRecipeFields() {
$field_instance = FieldConfig::load('node.recipe.recipe_ingredient');
$this
->assertSame('cup', $field_instance
->getSetting('default_unit'));
$display = EntityViewDisplay::load('node.recipe.default');
$field_component = $display
->getComponent('recipe_ingredient');
$this
->assertSame('{%d }%d/%d', $field_component['settings']['fraction_format']);
$this
->assertSame(1, $field_component['settings']['unit_display']);
$node = Node::load(1);
$this
->assertEquals('2', $node->recipe_ingredient[0]->quantity);
$this
->assertEquals('cup', $node->recipe_ingredient[0]->unit_key);
$this
->assertEquals('1', $node->recipe_ingredient[0]->target_id);
$this
->assertEquals('cold', $node->recipe_ingredient[0]->note);
$this
->assertEquals('1', $node->recipe_ingredient[1]->quantity);
$this
->assertEquals('tablespoon', $node->recipe_ingredient[1]->unit_key);
$this
->assertEquals('2', $node->recipe_ingredient[1]->target_id);
$this
->assertEquals('', $node->recipe_ingredient[1]->note);
}