You are here

public function PageTest::testVarByRef in Hook Event Dispatcher 8

The the vars by ref.

File

tests/src/Unit/Preprocess/PageTest.php, line 67

Class

PageTest
Class PageTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

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