You are here

public function PageTest::testGetVarByRef in Hook Event Dispatcher 3.x

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

Test getting a var by ref and changing it.

File

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

Class

PageTest
Class PageTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

public function testGetVarByRef() : void {
  $vars = [];
  $vars['page']['test'] = 'test';
  $page = new PageEventVariables($vars);
  $test =& $page
    ->getByReference('test');
  self::assertSame('test', $test);
  $test = 'OtherTest';
  self::assertSame('OtherTest', $page
    ->get('test'));
  self::assertSame('OtherTest', $vars['page']['test']);
}