You are here

public function PageTest::testGetVarByRef in Hook Event Dispatcher 8

Test getting a var by ref and changing it.

File

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

Class

PageTest
Class PageTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

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