Executes the iterator tests for the given entity type.
string $entity_type: The entity type to run the tests with.
protected function assertIterator($entity_type) {
$entity = $this
->createTestEntity($entity_type);
foreach ($entity as $name => $field) {
$this
->assertTrue($field instanceof FieldInterface, $entity_type . ": Field {$name} implements interface.");
foreach ($field as $delta => $item) {
$this
->assertTrue($field[0] instanceof FieldItemInterface, $entity_type . ": Item {$delta} of field {$name} implements interface.");
foreach ($item as $value_name => $value_property) {
$this
->assertTrue($value_property instanceof TypedDataInterface, $entity_type . ": Value {$value_name} of item {$delta} of field {$name} implements interface.");
$value = $value_property
->getValue();
$this
->assertTrue(!isset($value) || is_scalar($value) || $value instanceof EntityInterface, $entity_type . ": Value {$value_name} of item {$delta} of field {$name} is a primitive or an entity.");
}
}
}
$properties = $entity
->getProperties();
$this
->assertEqual(array_keys($properties), array_keys($entity
->getPropertyDefinitions()), format_string('%entity_type: All properties returned.', array(
'%entity_type' => $entity_type,
)));
$this
->assertEqual($properties, iterator_to_array($entity
->getIterator()), format_string('%entity_type: Entity iterator iterates over all properties.', array(
'%entity_type' => $entity_type,
)));
}