mockWebApplication(); } /** * @see https://github.com/yiisoft/yii2/issues/15536 */ public function testShouldTriggerInitEvent() { $initTriggered = false; $contentDecorator = new ContentDecorator( [ 'viewFile' => '@app/views/layouts/base.php', 'on init' => function () use (&$initTriggered) { $initTriggered = true; } ] ); ob_get_clean(); $this->assertTrue($initTriggered); } public function testAfterRunResultNotEmpty() { $result = null; ob_start(); ContentDecorator::begin([ 'viewFile' => '@yiiunit/data/views/layout.php', 'on afterRun' => function ($event) use (&$result) { $result = $event->result; }, ]); echo 'The Content'; ContentDecorator::end(); ob_end_clean(); $this->assertContains('The Content', $result); $this->assertContains('Test', $result); } }