mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 06:37:55 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			45 lines
		
	
	
		
			927 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			927 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * @link http://www.yiiframework.com/
 | 
						|
 * @copyright Copyright (c) 2008 Yii Software LLC
 | 
						|
 * @license http://www.yiiframework.com/license/
 | 
						|
 */
 | 
						|
 | 
						|
namespace yiiunit\framework\widgets;
 | 
						|
 | 
						|
use yii\widgets\ContentDecorator;
 | 
						|
 | 
						|
/**
 | 
						|
 * @group widgets
 | 
						|
 */
 | 
						|
class ContentDecoratorTest extends \yiiunit\TestCase
 | 
						|
{
 | 
						|
    protected function setUp()
 | 
						|
    {
 | 
						|
        parent::setUp();
 | 
						|
 | 
						|
        $this->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);
 | 
						|
    }
 | 
						|
}
 |