You are here

public function PageTest::testSet in Hook Event Dispatcher 8

Test the setter.

File

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

Class

PageTest
Class PageTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

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