You are here

public function TourTipPluginDefinitionDecoratorTest::testGetLabel in Plugin 8.2

@covers ::setLabel @covers ::getLabel

File

tests/src/Unit/PluginDefinition/TourTipPluginDefinitionDecoratorTest.php, line 46

Class

TourTipPluginDefinitionDecoratorTest
@coversDefaultClass \Drupal\plugin\PluginDefinition\TourTipPluginDefinitionDecorator

Namespace

Drupal\Tests\plugin\Unit\PluginDefinition

Code

public function testGetLabel() {

  // Test the injected value.
  $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']);

  // Test changing the value through the setter.
  $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']);

  // Test changing the value through array access.
  $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']);

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