You are here

public function PageTest::testGet in Hook Event Dispatcher 8.2

Same name and namespace in other branches
  1. 3.x modules/preprocess_event_dispatcher/tests/src/Unit/PageTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\PageTest::testGet()

Test the getter.

File

modules/preprocess_event_dispatcher/tests/src/Unit/PageTest.php, line 21

Class

PageTest
Class PageTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

public function testGet() : void {
  $vars = [];
  $vars['page']['test'] = TRUE;
  $vars['page']['array'] = [
    'array key' => 1,
  ];
  $vars['page']['object'] = new stdClass();
  $page = new PageEventVariables($vars);
  self::assertTrue($page
    ->get('test'));
  self::assertArrayHasKey('array key', $page
    ->get('array'));
  self::assertInstanceOf(stdClass::class, $page
    ->get('object'));
  self::assertFalse($page
    ->get('doesNotExists', FALSE));
}