ArchiverPluginDefinitionDecoratorTest.php in Plugin 8.2
File
tests/src/Unit/PluginDefinition/ArchiverPluginDefinitionDecoratorTest.php
View source
<?php
namespace Drupal\Tests\plugin\Unit\PluginDefinition;
use Drupal\plugin\PluginDefinition\ArchiverPluginDefinitionDecorator;
use Drupal\Tests\UnitTestCase;
class ArchiverPluginDefinitionDecoratorTest extends UnitTestCase {
protected $arrayDefinition = [];
protected $sut;
protected function setUp() : void {
parent::setUp();
$this->arrayDefinition = [
'title' => $this
->randomMachineName(),
];
$this->sut = new ArchiverPluginDefinitionDecorator($this->arrayDefinition);
}
public function testGetLabel() {
$this
->assertSame($this->arrayDefinition['title'], $this->sut
->getLabel());
$this
->assertSame($this->arrayDefinition['title'], $this->sut
->getArrayDefinition()['title']);
$this
->assertSame($this->arrayDefinition['title'], $this->sut['title']);
$value = $this
->randomMachineName();
$this
->assertSame($this->sut, $this->sut
->setLabel($value));
$this
->assertSame($value, $this->sut
->getLabel());
$this
->assertSame($value, $this->sut
->getArrayDefinition()['title']);
$this
->assertSame($value, $this->sut['title']);
$value = $this
->randomMachineName();
$this->sut['title'] = $value;
$this
->assertSame($value, $this->sut
->getLabel());
$this
->assertSame($value, $this->sut
->getArrayDefinition()['title']);
$this
->assertSame($value, $this->sut['title']);
unset($this->sut['title']);
$this
->assertFalse(isset($this->sut['title']));
$this
->assertNull($this->sut
->getLabel());
$this
->assertFalse(isset($this->sut
->getArrayDefinition()['title']));
}
}