function EntityAdapterUnitTest::testGetIterator

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php \Drupal\Tests\Core\Entity\TypedData\EntityAdapterUnitTest::testGetIterator()
  2. 9 core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php \Drupal\Tests\Core\Entity\TypedData\EntityAdapterUnitTest::testGetIterator()
  3. 8.9.x core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php \Drupal\Tests\Core\Entity\TypedData\EntityAdapterUnitTest::testGetIterator()

Tests get iterator.

File

core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php, line 441

Class

EntityAdapterUnitTest
Tests Drupal\Core\Entity\Plugin\DataType\EntityAdapter.

Namespace

Drupal\Tests\Core\Entity\TypedData

Code

public function testGetIterator() : void {
  // Content entity test.
  $iterator = $this->entityAdapter
    ->getIterator();
  $fields = iterator_to_array($iterator);
  $this->assertArrayHasKey('id', $fields);
  $this->assertArrayHasKey('revision_id', $fields);
  $this->assertCount(2, $fields);
  $this->entityAdapter
    ->setValue(NULL);
  $this->assertEquals(new \ArrayIterator([]), $this->entityAdapter
    ->getIterator());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.