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