You are here

public function PluginTestBase::testGetProperty in Purge 8.3

Test retrieving a property.

See also

\Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface::getProperty

File

tests/src/Kernel/Invalidation/PluginTestBase.php, line 141

Class

PluginTestBase
Provides an abstract test class to thoroughly test invalidation types.

Namespace

Drupal\Tests\purge\Kernel\Invalidation

Code

public function testGetProperty() : void {
  $i = $this
    ->getInstance();
  $i
    ->setStateContext('purger_b');
  $i
    ->setProperty('my_book', 'Nineteen Eighty-Four');
  $this
    ->assertSame('Nineteen Eighty-Four', $i
    ->getProperty('my_book'));
  $this
    ->assertSame(NULL, $i
    ->getProperty('my_film'));

  // Test again within a different context.
  $i
    ->setState(InvalidationInterface::FAILED);
  $i
    ->setStateContext('purger_b2');
  $this
    ->assertSame(NULL, $i
    ->getProperty('my_book'));
}