You are here

public function RabbitHoleBehaviorPluginTest::testPluginManager in Rabbit Hole 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/RabbitHoleBehaviorPluginTest.php \Drupal\Tests\rabbit_hole\Functional\RabbitHoleBehaviorPluginTest::testPluginManager()

Test the plugin manager.

File

tests/src/Functional/RabbitHoleBehaviorPluginTest.php, line 66

Class

RabbitHoleBehaviorPluginTest
Test the functionality of the RabbitHoleBehavior plugin.

Namespace

Drupal\Tests\rabbit_hole\Functional

Code

public function testPluginManager() {

  // Check that we can get a behavior plugin.
  $this
    ->assertNotNull($this->manager, 'Drupal plugin service returned a rabbit hole behavior service.');

  // Check that the behavior plugin manager is the type we expect.
  $this
    ->assertInstanceOf(RabbitHoleBehaviorPluginManager::class, $this->manager);

  // Check the rabbit_hole module defines the expected number of behaviors.
  $behaviors = $this->manager
    ->getDefinitions();
  $this
    ->assertCount(4, $behaviors, 'There are 4 behaviors.');

  // Check that the plugins defined by the rabbit_hole module are in the list
  // of plugins.
  $this
    ->assertTrue($this->manager
    ->hasDefinition('access_denied'), 'There is an access denied plugin');
  $this
    ->assertArrayHasKey('label', $behaviors['access_denied'], 'The access denied plugin has a label');
  $this
    ->assertTrue($this->manager
    ->hasDefinition('display_page'), 'There is a display the page plugin');
  $this
    ->assertArrayHasKey('label', $behaviors['display_page'], 'The display the page plugin has a label');
  $this
    ->assertTrue($this->manager
    ->hasDefinition('page_not_found'), 'There is a page not found plugin');
  $this
    ->assertArrayHasKey('label', $behaviors['page_not_found'], 'The page not found plugin has a label');
  $this
    ->assertTrue($this->manager
    ->hasDefinition('page_redirect'), 'There is a page redirect plugin');
  $this
    ->assertArrayHasKey('label', $behaviors['page_redirect'], 'The page redirect plugin has a label');
}