Bootstrap\Test\TestCase\View\Helper\BootstrapPanelHelperTest::testHeader PHP Метод

testHeader() публичный Метод

public testHeader ( )
    public function testHeader()
    {
        $content = 'Header';
        $htmlContent = '<b>' . $content . '</b>';
        $extraclass = 'my-extra-class';
        // Simple test
        $result = $this->Panel->header($content);
        $this->assertHtml([['div' => ['class' => 'panel-heading']], ['h4' => ['class' => 'panel-title']], $content, '/h4', '/div'], $result);
        $this->reset();
        // Test with HTML content (should be escaped)
        $result = $this->Panel->header($htmlContent);
        $this->assertHtml([['div' => ['class' => 'panel-heading']], ['h4' => ['class' => 'panel-title']], htmlspecialchars($htmlContent), '/h4', '/div'], $result);
        $this->reset();
        // Test with HTML content (should NOT be escaped)
        $result = $this->Panel->header($htmlContent, ['escape' => false]);
        $this->assertHtml([['div' => ['class' => 'panel-heading']], ['h4' => ['class' => 'panel-title']], ['b' => true], $content, '/b', '/h4', '/div'], $result);
        $this->reset();
        // Test with icon
        $iconContent = 'i:home Home';
        $result = $this->Panel->header($iconContent);
        $this->assertHtml([['div' => ['class' => 'panel-heading']], ['h4' => ['class' => 'panel-title']], ['i' => ['class' => 'glyphicon glyphicon-home', 'aria-hidden' => 'true']], '/i', ' Home', '/h4', '/div'], $result);
        $this->reset();
        // Test with collapsible (should NOT be escaped)
        // Test with HTML content (should be escaped)
        $this->Panel->create(null, ['collapsible' => true]);
        $result = $this->Panel->header($htmlContent);
        $this->assertHtml([['div' => ['role' => 'tab', 'id' => 'heading-0', 'class' => 'panel-heading']], ['h4' => ['class' => 'panel-title']], ['a' => ['href' => '#collapse-0', 'data-toggle' => 'collapse', 'aria-expanded' => 'true', 'aria-controls' => '#collapse-0']], htmlspecialchars($htmlContent), '/a', '/h4', '/div'], $result);
        $this->reset();
        // Test with HTML content (should NOT be escaped)
        $this->Panel->create(null, ['collapsible' => true]);
        $result = $this->Panel->header($htmlContent, ['escape' => false]);
        $this->assertHtml([['div' => ['role' => 'tab', 'id' => 'heading-1', 'class' => 'panel-heading']], ['h4' => ['class' => 'panel-title']], ['a' => ['href' => '#collapse-1', 'data-toggle' => 'collapse', 'aria-expanded' => 'true', 'aria-controls' => '#collapse-1']], ['b' => true], $content, '/b', '/a', '/h4', '/div'], $result);
        $this->reset();
        // Test with icon
        $iconContent = 'i:home Home';
        $this->Panel->create(null, ['collapsible' => true]);
        $result = $this->Panel->header($iconContent);
        $this->assertHtml([['div' => ['role' => 'tab', 'id' => 'heading-2', 'class' => 'panel-heading']], ['h4' => ['class' => 'panel-title']], ['a' => ['href' => '#collapse-2', 'data-toggle' => 'collapse', 'aria-expanded' => 'true', 'aria-controls' => '#collapse-2']], ['i' => ['class' => 'glyphicon glyphicon-home', 'aria-hidden' => 'true']], '/i', ' Home', '/a', '/h4', '/div'], $result);
        $this->reset();
    }