Skip to content

Commit

Permalink
Refactor asset registration and update asset manager configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Feb 28, 2024
1 parent 70abbf2 commit 54901ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
16 changes: 5 additions & 11 deletions tests/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ public function testDateTimePickerAssetSimpleDependency(): void

public function testDateTimePickerAssetRegister(): void
{
$this->assertEmpty($this->view->assetBundles);

JQueryProviderAsset::register($this->view);

$this->assertCount(3, $this->view->assetBundles);

$result = $this->view->renderFile(
__DIR__ . '/Support/main.php',
[
Expand All @@ -62,11 +56,11 @@ public function testDateTimePickerAssetRegister(): void
],
);

$this->assertStringNotContainsString('css/tempus-dominus.min.css', $result);
$this->assertStringNotContainsString('js/tempus-dominus.min.js', $result);
$this->assertStringNotContainsString('jQuery-provider.min.js', $result);
$this->assertStringNotContainsString('popper.min.js', $result);
$this->assertStringNotContainsString('jquery.min.js', $result);
$directory = __DIR__ . '/Support/runtime/16b8de20';

$this->assertDirectoryDoesNotExist("$directory/css/tempus-dominus.min.css");
$this->assertDirectoryDoesNotExist("$directory/css/js/tempus-dominus.min.js");
$this->assertDirectoryDoesNotExist("$directory/css/js/jQuery-provider.min.js");
$this->assertStringContainsString('css/tempus-dominus.css', $result);
$this->assertStringContainsString('js/tempus-dominus.js', $result);
$this->assertStringContainsString('jQuery-provider.js', $result);
Expand Down
5 changes: 5 additions & 0 deletions tests/Support/TestSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function mockApplication(): void
'appendTimestamp' => false,
'basePath' => __DIR__ . '/runtime',
'baseUrl' => '/',
'forceCopy' => true,
],
'i18n' => [
'translations' => [
Expand All @@ -55,6 +56,10 @@ protected function mockApplication(): void
],
],
);

Yii::$app->assetManager->hashCallback = static function (string $path) {
return '16b8de20';
};
}

/**
Expand Down

0 comments on commit 54901ec

Please sign in to comment.