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