mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 14:46:19 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			850 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			850 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
/**
 | 
						|
 * @link https://www.yiiframework.com/
 | 
						|
 * @copyright Copyright (c) 2008 Yii Software LLC
 | 
						|
 * @license https://www.yiiframework.com/license/
 | 
						|
 */
 | 
						|
 | 
						|
namespace yiiunit\framework\widgets;
 | 
						|
 | 
						|
use yiiunit\TestCase;
 | 
						|
use yii\widgets\Block;
 | 
						|
 | 
						|
/**
 | 
						|
 * @group widgets
 | 
						|
 */
 | 
						|
class BlockTest extends TestCase
 | 
						|
{
 | 
						|
    protected function setUp(): void
 | 
						|
    {
 | 
						|
        parent::setUp();
 | 
						|
 | 
						|
        $this->mockWebApplication();
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * @see https://github.com/yiisoft/yii2/issues/15536
 | 
						|
     */
 | 
						|
    public function testShouldTriggerInitEvent(): void
 | 
						|
    {
 | 
						|
        $initTriggered = false;
 | 
						|
 | 
						|
        $block = new Block(
 | 
						|
            [
 | 
						|
                'on init' => function () use (&$initTriggered) {
 | 
						|
                    $initTriggered = true;
 | 
						|
                }
 | 
						|
            ]
 | 
						|
        );
 | 
						|
 | 
						|
        ob_get_clean();
 | 
						|
 | 
						|
        $this->assertTrue($initTriggered);
 | 
						|
    }
 | 
						|
}
 |