You are here

public function ArrayPluginDefinitionDecoratorTest::testGetDeriverClass in Plugin 8.2

@covers ::setDeriverClass @covers ::getDeriverClass @covers ::offsetExists @covers ::offsetSet @covers ::offsetGet @covers ::offsetUnset

File

tests/src/Unit/PluginDefinition/ArrayPluginDefinitionDecoratorTest.php, line 224

Class

ArrayPluginDefinitionDecoratorTest
@coversDefaultClass \Drupal\plugin\PluginDefinition\ArrayPluginDefinitionDecorator

Namespace

Drupal\Tests\plugin\Unit\PluginDefinition

Code

public function testGetDeriverClass() {

  // Test the injected value.
  $this
    ->assertSame($this->arrayDefinition['deriver'], $this->sut
    ->getDeriverClass());
  $this
    ->assertSame($this->arrayDefinition['deriver'], $this->sut
    ->getArrayDefinition()['deriver']);
  $this
    ->assertSame($this->arrayDefinition['deriver'], $this->sut['deriver']);

  // Test changing the value through the setter.
  $value = $this
    ->getMockClass(DeriverInterface::class);
  $this
    ->assertSame($this->sut, $this->sut
    ->setDeriverClass($value));
  $this
    ->assertSame($value, $this->sut
    ->getDeriverClass());
  $this
    ->assertSame($value, $this->sut
    ->getArrayDefinition()['deriver']);
  $this
    ->assertSame($value, $this->sut['deriver']);

  // Test changing the value through array access.
  $value = $this
    ->getMockClass(DeriverInterface::class);
  $this->sut['deriver'] = $value;
  $this
    ->assertSame($value, $this->sut
    ->getDeriverClass());
  $this
    ->assertSame($value, $this->sut
    ->getArrayDefinition()['deriver']);
  $this
    ->assertSame($value, $this->sut['deriver']);

  // Test unsetting the value.
  unset($this->sut['deriver']);
  $this
    ->assertFalse(isset($this->sut['deriver']));
  $this
    ->assertNull($this->sut
    ->getDeriverClass());
  $this
    ->assertFalse(isset($this->sut
    ->getArrayDefinition()['deriver']));
}