Skip to content

Commit

Permalink
Fix assets.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 17, 2023
1 parent ed3c5eb commit 7d9de5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/BootstrapAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Twitter Bootstrap 5 CSS bundle.
*/
class BootstrapAsset extends AssetBundle
final class BootstrapAsset extends AssetBundle
{
/**
* @inheritDoc
Expand All @@ -20,9 +20,11 @@ public function init(): void
{
parent::init();

$assetBootstrap = YII_ENV === 'prod' ? 'bootstrap.min.css' : 'bootstrap.css';
$assetBootstrap = YII_ENV === 'prod'
? ['bootstrap.min.css', 'bootstrap.min.css.map']
: ['bootstrap.css', 'bootstrap.css.map'];

$this->js[] = $assetBootstrap;
$this->publishOptions['only'] = [$assetBootstrap];
$this->css = $assetBootstrap;
$this->publishOptions['only'] = $assetBootstrap;
}
}
10 changes: 6 additions & 4 deletions src/BootstrapPluginAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Twitter Bootstrap 5 JavaScript bundle.
*/
class BootstrapPluginAsset extends AssetBundle
final class BootstrapPluginAsset extends AssetBundle
{
/**
* @inheritDoc
Expand All @@ -27,9 +27,11 @@ public function init(): void
{
parent::init();

$assetBootstrapPlugin = YII_ENV === 'prod' ? 'bootstrap.bundle.min.js' : 'bootstrap.bundle.js';
$assetBootstrapPlugin = YII_ENV === 'prod'
? ['bootstrap.bundle.min.js', 'bootstrap.bundle.min.js.map']
: ['bootstrap.bundle.js', 'bootstrap.bundle.js.map'];

$this->js[] = $assetBootstrapPlugin;
$this->publishOptions['only'] = [$assetBootstrapPlugin];
$this->js = $assetBootstrapPlugin;
$this->publishOptions['only'] = $assetBootstrapPlugin;
}
}
9 changes: 6 additions & 3 deletions tests/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function testBootstrapAssetRegister(): void

$result = $view->renderFile(__DIR__ . '/support/main.php');

$this->assertMatchesRegularExpression('/bootstrap.css/', $result);
$this->assertStringContainsString('bootstrap.css', $result);
$this->assertStringContainsString('bootstrap.css.map', $result);
}

public function testBootstrapPluginAssetSimpleDependency(): void
Expand Down Expand Up @@ -86,8 +87,10 @@ public function testBootstrapPluginAssetRegister(): void

$result = $view->renderFile(__DIR__ . '/support/main.php');

$this->assertMatchesRegularExpression('/bootstrap.css/', $result);
$this->assertMatchesRegularExpression('/bootstrap.bundle.js/', $result);
$this->assertStringContainsString('bootstrap.css', $result);
$this->assertStringContainsString('bootstrap.css.map', $result);
$this->assertStringContainsString('bootstrap.bundle.js', $result);
$this->assertStringContainsString('bootstrap.bundle.js.map', $result);
}

private function sourcesPublishVerifyFiles(string $type, object $bundle): void
Expand Down

0 comments on commit 7d9de5e

Please sign in to comment.