for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Yiisoft\Widget\Tests;
use Yiisoft\Tests\TestCase;
use Yiisoft\Widget\Block;
use Yiisoft\Widget\Event\BeforeRun;
/**
* @group widgets
*/
class BlockTest extends TestCase
{
public function testBlock(): void
Block::begin()
->id('testme')
->init();
echo '<block-testme>';
Block::end();
$this->assertStringContainsString('<block-testme>', $this->webView->getBlock('testme'));
}
public function testBlockRenderInPlaceTrue(): void
ob_start();
ob_implicit_flush(0);
->renderInPlace(true)
$this->assertStringContainsString('<block-testme>', ob_get_clean());
public function testGetBlockException(): void
$this->expectException(\InvalidArgumentException::class);
$this->webView->getBlock('notfound');
* @see https://github.com/yiisoft/yii2/issues/15536
public function testShouldTriggerInitEvent(): void
$initTriggered = false;
// adding some listeners
$this->listenerProvider->attach(function (BeforeRun $event) use (&$initTriggered) {
$event
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
$this->listenerProvider->attach(function (/** @scrutinizer ignore-unused */ BeforeRun $event) use (&$initTriggered) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$initTriggered = true;
});
Block::begin()->init();
ob_get_clean();
$this->assertTrue($initTriggered);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.