->
setComponent($this->fieldTestData->field_name,
[ 'type' => 'field_test_with_prepare_view',
]);
// Create two entities.
$entity1 = EntityTest::
create(['id' => 1, 'type' => 'entity_test'
]);
$entity1->
{$this->fieldTestData->field_name
}->
setValue($this->
_generateTestFieldValues(1
));
$entity2 = EntityTest::
create(['id' => 2, 'type' => 'entity_test'
]);
$entity2->
{$this->fieldTestData->field_name
}->
setValue($this->
_generateTestFieldValues(1
));
// Run buildMultiple(), and check that the entities come out as expected.
$display->
buildMultiple([$entity1,
$entity2]);
$item1 =
$entity1->
{$this->fieldTestData->field_name
}[0
];
$this->
assertEquals($item1->value + 1,
$item1->additional_formatter_value, 'Entity 1 ran through the prepareView() formatter method.'
);
$item2 =
$entity2->
{$this->fieldTestData->field_name
}[0
];
$this->
assertEquals($item2->value + 1,
$item2->additional_formatter_value, 'Entity 2 ran through the prepareView() formatter method.'
);
} /**
* Tests entity cache.
*
* Complements unit test coverage in
* \Drupal\Tests\Core\Entity\Sql\SqlContentEntityStorageTest.
*/