set popover title to default null (to prevent error)
added popover tests switched to bower asset to allow installation of bs4 and bs5
This commit is contained in:
parent
8a7fffd570
commit
f696aa0421
@ -28,7 +28,7 @@
|
||||
"php": ">=7.4.0",
|
||||
"ext-json": "*",
|
||||
"yiisoft/yii2": "^2.0.42",
|
||||
"npm-asset/bootstrap": "^5.0.0"
|
||||
"bower-asset/bootstrap": "^5.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"yiisoft/yii2-coding-standards": "~2.0",
|
||||
|
@ -8,7 +8,7 @@ use yii\web\AssetBundle;
|
||||
|
||||
class BootstrapAsset extends AssetBundle
|
||||
{
|
||||
public $sourcePath = '@npm/bootstrap/dist';
|
||||
public $sourcePath = '@bower/bootstrap/dist';
|
||||
|
||||
public $css = [
|
||||
'css/bootstrap.css',
|
||||
|
@ -13,7 +13,7 @@ use yii\web\AssetBundle;
|
||||
*/
|
||||
class BootstrapPluginAsset extends AssetBundle
|
||||
{
|
||||
public $sourcePath = '@npm/bootstrap/dist';
|
||||
public $sourcePath = '@bower/bootstrap/dist';
|
||||
public $js = [
|
||||
'js/bootstrap.bundle.js',
|
||||
];
|
||||
|
@ -44,7 +44,7 @@ class Popover extends Widget
|
||||
/**
|
||||
* @var string|null the tile content in the popover.
|
||||
*/
|
||||
public ?string $title;
|
||||
public ?string $title = null;
|
||||
/**
|
||||
* @var array additional header options
|
||||
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
|
||||
|
@ -2,13 +2,61 @@
|
||||
|
||||
namespace yiiunit\extensions\bootstrap5;
|
||||
|
||||
use Yii;
|
||||
use yii\bootstrap5\Html;
|
||||
use yii\bootstrap5\Popover;
|
||||
use yii\web\View;
|
||||
|
||||
/**
|
||||
* @group bootstrap5
|
||||
*/
|
||||
class PopoverTest extends TestCase
|
||||
{
|
||||
// TODO
|
||||
public function testButtonRender()
|
||||
{
|
||||
Popover::$counter = 0;
|
||||
$out = Popover::widget(['toggleButton' => ['class' => ['btn', 'btn-primary']]]);
|
||||
|
||||
$expected = <<<HTML
|
||||
<button type="button" id="w0" class="btn btn-primary">Show</button>
|
||||
HTML;
|
||||
|
||||
$this->assertEqualsWithoutLE($expected, $out);
|
||||
}
|
||||
|
||||
public function testClientOptions()
|
||||
{
|
||||
Popover::$counter = 0;
|
||||
Popover::widget([
|
||||
'headerOptions' => ['class' => ['test-header']],
|
||||
'placement' => Popover::PLACEMENT_BOTTOM,
|
||||
'title' => 'Test Popover'
|
||||
]);
|
||||
|
||||
$js = Yii::$app->view->js[View::POS_READY];
|
||||
|
||||
$this->assertIsArray($js);
|
||||
$options = array_shift($js);
|
||||
|
||||
$this->assertContainsWithoutLE("jQuery('#w0').popover({", $options);
|
||||
$this->assertContainsWithoutLE("id=\u0022w0-popover\u0022", $options);
|
||||
$this->assertContainsWithoutLE("class=\u0022test-header popover-header\u0022", $options);
|
||||
$this->assertContainsWithoutLE('"placement":"bottom"', $options);
|
||||
$this->assertContainsWithoutLE('"title":"Test Popover"', $options);
|
||||
}
|
||||
|
||||
public function testContent()
|
||||
{
|
||||
Popover::$counter = 0;
|
||||
Popover::begin([]);
|
||||
echo Html::tag('span', 'Test content', ['class' => ['test-content']]);
|
||||
Popover::end();
|
||||
|
||||
$js = Yii::$app->view->js[View::POS_READY];
|
||||
|
||||
$this->assertIsArray($js);
|
||||
$options = array_shift($js);
|
||||
|
||||
$this->assertContainsWithoutLE('"content":"\u003Cspan class=\u0022test-content\u0022\u003ETest content\u003C\/span\u003E"', $options);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user