function ConfigEntityAdapterTest::testGetIterator
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php \Drupal\KernelTests\Core\Entity\ConfigEntityAdapterTest::testGetIterator()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php \Drupal\KernelTests\Core\Entity\ConfigEntityAdapterTest::testGetIterator()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php \Drupal\KernelTests\Core\Entity\ConfigEntityAdapterTest::testGetIterator()
@covers ::getIterator
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ ConfigEntityAdapterTest.php, line 158
Class
- ConfigEntityAdapterTest
- Tests entity adapter for configuration entities.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testGetIterator() : void {
$adapter = ConfigEntityAdapter::createFromEntity($this->entity);
$iterator = $adapter->getIterator();
$fields = iterator_to_array($iterator);
$expected_fields = [
'uuid',
'langcode',
'status',
'dependencies',
'id',
'label',
'weight',
'style',
'size',
'size_value',
'protected_property',
];
$this->assertEquals($expected_fields, array_keys($fields));
$this->assertEquals($this->entity
->id(), $fields['id']->getValue());
$adapter->setValue(NULL);
$this->assertEquals(new \ArrayIterator([]), $adapter->getIterator());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.