public function ArrayPluginDefinitionDecoratorTest::testGetParentId in Plugin 8.2
@covers ::setParentId @covers ::getParentId @covers ::offsetExists @covers ::offsetSet @covers ::offsetGet @covers ::offsetUnset
File
- tests/
src/ Unit/ PluginDefinition/ ArrayPluginDefinitionDecoratorTest.php, line 513
Class
- ArrayPluginDefinitionDecoratorTest
- @coversDefaultClass \Drupal\plugin\PluginDefinition\ArrayPluginDefinitionDecorator
Namespace
Drupal\Tests\plugin\Unit\PluginDefinitionCode
public function testGetParentId() {
// Test the injected value.
$this
->assertSame($this->arrayDefinition['parent_id'], $this->sut
->getParentId());
$this
->assertSame($this->arrayDefinition['parent_id'], $this->sut
->getArrayDefinition()['parent_id']);
$this
->assertSame($this->arrayDefinition['parent_id'], $this->sut['parent_id']);
// Test changing the value through the setter.
$value = $this
->randomMachineName();
$this
->assertSame($this->sut, $this->sut
->setParentId($value));
$this
->assertSame($value, $this->sut
->getParentId());
$this
->assertSame($value, $this->sut
->getArrayDefinition()['parent_id']);
$this
->assertSame($value, $this->sut['parent_id']);
// Test changing the value through array access.
$value = $this
->randomMachineName();
$this->sut['parent_id'] = $value;
$this
->assertSame($value, $this->sut
->getParentId());
$this
->assertSame($value, $this->sut
->getArrayDefinition()['parent_id']);
$this
->assertSame($value, $this->sut['parent_id']);
// Test unsetting the value.
unset($this->sut['parent_id']);
$this
->assertFalse(isset($this->sut['parent_id']));
$this
->assertNull($this->sut
->getParentId());
$this
->assertFalse(isset($this->sut
->getArrayDefinition()['parent_id']));
}