diff --git a/src/Asset/DateTimePickerAsset.php b/src/Asset/DateTimePickerAsset.php index bd54ae4..4c44c76 100644 --- a/src/Asset/DateTimePickerAsset.php +++ b/src/Asset/DateTimePickerAsset.php @@ -19,6 +19,7 @@ final class DateTimePickerAsset extends AssetBundle */ public $depends = [ PopperAsset::class, + JQueryProviderAsset::class, ]; public function __construct() diff --git a/src/Asset/DateTimePickerCdnAsset.php b/src/Asset/DateTimePickerCdnAsset.php index f3a797e..01a1d45 100644 --- a/src/Asset/DateTimePickerCdnAsset.php +++ b/src/Asset/DateTimePickerCdnAsset.php @@ -23,15 +23,25 @@ public function init(): void { parent::init(); - $this->css = ['https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.19/dist/css/tempus-dominus.min.css']; + $this->css = ['https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.5/dist/css/tempus-dominus.min.css']; $this->cssOptions = [ 'crossorigin' => 'anonymous', + 'integrity' => 'sha256-CnrhpfYrXdEi7tt7MaXkXnjHOtTw2WUF/ZtHsRYTd9o=', 'rel' => 'stylesheet', ]; - $this->js = ['https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.19/dist/js/tempus-dominus.min.js']; - $this->jsOptions = [ - 'crossorigin' => 'anonymous', - 'rel' => 'stylesheet', + $this->js = [ + [ + 'https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.5/dist/js/jQuery-provider.min.js', + 'crossorigin' => 'anonymous', + 'integrity' => 'sha256-NMrbeybKZu57CqLc5IecBME3FpiCIhcicPBoZCQ2gXc=', + 'rel' => 'stylesheet', + ], + [ + 'https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.5/dist/js/tempus-dominus.min.js', + 'crossorigin' => 'anonymous', + 'integrity' => 'sha256-HhK4pzV6V5uvaAYnvGv7rdtJPnECOyPE5ht/eE6dvYw=', + 'rel' => 'stylesheet', + ], ]; } } diff --git a/src/Asset/JQueryProviderAsset.php b/src/Asset/JQueryProviderAsset.php new file mode 100644 index 0000000..cfb9d29 --- /dev/null +++ b/src/Asset/JQueryProviderAsset.php @@ -0,0 +1,26 @@ +js = [$jsFiles]; + $this->publishOptions['only'] = [$jsFiles]; + } +} diff --git a/tests/AssetTest.php b/tests/AssetTest.php index 86133ae..3bbd3c3 100644 --- a/tests/AssetTest.php +++ b/tests/AssetTest.php @@ -27,7 +27,7 @@ public function testDateTimePickerAssetSimpleDependency(): void DateTimePickerAsset::register($this->view); - $this->assertCount(2, $this->view->assetBundles); + $this->assertCount(3, $this->view->assetBundles); $this->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[DateTimePickerAsset::class]); $this->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[PopperAsset::class]); @@ -39,7 +39,7 @@ public function testDateTimePickerAssetRegister(): void DateTimePickerAsset::register($this->view); - $this->assertCount(2, $this->view->assetBundles); + $this->assertCount(3, $this->view->assetBundles); $result = $this->view->renderFile( __DIR__ . '/Support/main.php', @@ -55,6 +55,8 @@ public function testDateTimePickerAssetRegister(): void $this->assertStringContainsString('css/tempus-dominus.css', $result); $this->assertStringContainsString('js/tempus-dominus.js', $result); + $this->assertStringContainsString('popper.js', $result); + $this->assertStringContainsString('JQuery-provider.js', $result); $this->assertStringContainsString('jquery.js', $result); } @@ -93,7 +95,7 @@ public function testDateTimePickerCdnAssetRegister(): void $this->assertStringContainsString( << + HTML, $result, ); @@ -105,7 +107,13 @@ public function testDateTimePickerCdnAssetRegister(): void ); $this->assertStringContainsString( << + + HTML, + $result, + ); + $this->assertStringContainsString( + << HTML, $result, );