public function ConfigEntityAdapterTest::testSet in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php \Drupal\KernelTests\Core\Entity\ConfigEntityAdapterTest::testSet()
@covers ::set
File
- core/tests/ Drupal/ KernelTests/ Core/ Entity/ ConfigEntityAdapterTest.php, line 119 
Class
- ConfigEntityAdapterTest
- Tests entity adapter for configuration entities.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testSet() {
  $adapter = ConfigEntityAdapter::createFromEntity($this->entity);
  // Get the value via typed data to ensure that the typed representation is
  // updated correctly when the value is set.
  $this
    ->assertEquals(1, $adapter
    ->get('weight')
    ->getValue());
  $return = $adapter
    ->set('weight', 2);
  $this
    ->assertSame($adapter, $return);
  $this
    ->assertEquals(2, $this->entity->weight);
  // Ensure the typed data is updated via the set too.
  $this
    ->assertEquals(2, $adapter
    ->get('weight')
    ->getValue());
}