diff --git a/tests/SelectizeTest.php b/tests/SelectizeTest.php index e8cfe6f..7b2a8e6 100644 --- a/tests/SelectizeTest.php +++ b/tests/SelectizeTest.php @@ -19,6 +19,8 @@ public function setup(): void parent::setUp(); $this->mockApplication(); + Selectize::$counter = 0; + $this->view = Yii::$app->getView(); } @@ -138,7 +140,7 @@ public function testItemsWithTypeTextInput(): void public function testLoadUrl(): void { - $selectizeDropdownList = Selectize::widget( + $selectize = Selectize::widget( [ 'attribute' => 'tags', 'loadUrl' => '/tags', @@ -146,12 +148,7 @@ public function testLoadUrl(): void ], ); - $render = $this->view->renderFile( - __DIR__ . '/Support/main.php', - [ - 'widget' => $selectizeDropdownList, - ], - ); + $render = $this->view->renderFile(__DIR__ . '/Support/main.php', ['widget' => $selectize]); Assert::equalsWithoutLE( << HTML, - $selectizeDropdownList, + $selectize, ); $this->assertStringContainsString( @@ -202,19 +199,14 @@ public function testLoadUrlWithTypeTextInput(): void public function testRender(): void { - $selectizeDropdownList = Selectize::widget( + $selectize = Selectize::widget( [ 'attribute' => 'tags', 'model' => new SelectizeModel(), ], ); - $render = $this->view->renderFile( - __DIR__ . '/Support/main.php', - [ - 'widget' => $selectizeDropdownList, - ], - ); + $render = $this->view->renderFile(__DIR__ . '/Support/main.php', ['widget' => $selectize]); Assert::equalsWithoutLE( << HTML, - $selectizeDropdownList, + $selectize, ); $this->assertStringContainsString( @@ -264,14 +256,9 @@ public function testRenderWithTypeTextInput(): void public function testWithoutModel(): void { - $selectizeDropdownList = Selectize::widget(['name' => 'tags']); + $selectize = Selectize::widget(['name' => 'tags']); - $render = $this->view->renderFile( - __DIR__ . '/Support/main.php', - [ - 'widget' => $selectizeDropdownList, - ], - ); + $render = $this->view->renderFile(__DIR__ . '/Support/main.php', ['widget' => $selectize]); Assert::equalsWithoutLE( << HTML, - $selectizeDropdownList, + $selectize, ); $this->assertStringContainsString( @@ -300,7 +287,7 @@ public function testWithoutModelWithTypeTextInput(): void Assert::equalsWithoutLE( << + HTML, @@ -310,7 +297,7 @@ public function testWithoutModelWithTypeTextInput(): void $this->assertStringContainsString( <<jQuery(function ($) { - jQuery('#w1').selectize([]); + jQuery('#w0').selectize([]); }); JS, $render, diff --git a/tests/TestCase.php b/tests/TestCase.php index 37d8fec..a8b234a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -34,7 +34,7 @@ protected function mockApplication(): void '@bower' => '@root/node_modules', '@npm' => '@root/node_modules', ], - 'basePath' => __DIR__, + 'basePath' => dirname(__DIR__), 'components' => [ 'assetManager' => [ 'basePath' => __DIR__ . '/Support/runtime',