Skip to content

Commit

Permalink
Fix CDN asset file names and add jQuery provider asset. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw authored Feb 28, 2024
1 parent e107da3 commit f9630f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Asset/DateTimePickerCdnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public function init(): void
];
$this->js = [
[
'https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.5/dist/js/jQuery-provider.min.js',
'https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.5/dist/js/tempus-dominus.min.js',
'crossorigin' => 'anonymous',
'integrity' => 'sha256-NMrbeybKZu57CqLc5IecBME3FpiCIhcicPBoZCQ2gXc=',
'integrity' => 'sha256-HhK4pzV6V5uvaAYnvGv7rdtJPnECOyPE5ht/eE6dvYw=',
'rel' => 'stylesheet',
],
[
'https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.5/dist/js/tempus-dominus.min.js',
'https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.9.5/dist/js/jQuery-provider.min.js',
'crossorigin' => 'anonymous',
'integrity' => 'sha256-HhK4pzV6V5uvaAYnvGv7rdtJPnECOyPE5ht/eE6dvYw=',
'integrity' => 'sha256-NMrbeybKZu57CqLc5IecBME3FpiCIhcicPBoZCQ2gXc=',
'rel' => 'stylesheet',
],
];
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/JQueryProviderAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct()
parent::__construct();

$environment = defined('YII_ENV') ? YII_ENV : 'prod';
$jsFiles = $environment === 'prod' ? 'JQuery-provider.min.js' : 'JQuery-provider.js';
$jsFiles = $environment === 'prod' ? 'jQuery-provider.min.js' : 'jQuery-provider.js';

$this->js = [$jsFiles];
$this->publishOptions['only'] = [$jsFiles];

Check warning on line 24 in src/Asset/JQueryProviderAsset.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ $environment = defined('YII_ENV') ? YII_ENV : 'prod'; $jsFiles = $environment === 'prod' ? 'jQuery-provider.min.js' : 'jQuery-provider.js'; $this->js = [$jsFiles]; - $this->publishOptions['only'] = [$jsFiles]; + $this->publishOptions['only'] = []; } }
Expand Down
10 changes: 8 additions & 2 deletions tests/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
namespace Yii2\Extensions\DateTimePicker\Tests;

use Yii2\Asset\{PopperAsset, PopperCdnAsset};
use Yii2\Extensions\DateTimePicker\{Asset\DateTimePickerAsset, Asset\DateTimePickerCdnAsset, DateTimePicker};
use Yii2\Extensions\DateTimePicker\{
Asset\DateTimePickerAsset,
Asset\DateTimePickerCdnAsset,
Asset\JQueryProviderAsset,
DateTimePicker
};
use Yii;
use yii\web\AssetBundle;

Expand All @@ -31,6 +36,7 @@ public function testDateTimePickerAssetSimpleDependency(): void

$this->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[DateTimePickerAsset::class]);
$this->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[PopperAsset::class]);
$this->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[JQueryProviderAsset::class]);
}

public function testDateTimePickerAssetRegister(): void
Expand All @@ -55,8 +61,8 @@ public function testDateTimePickerAssetRegister(): void

$this->assertStringContainsString('css/tempus-dominus.css', $result);
$this->assertStringContainsString('js/tempus-dominus.js', $result);
$this->assertStringContainsString('jQuery-provider.js', $result);
$this->assertStringContainsString('popper.js', $result);
$this->assertStringContainsString('JQuery-provider.js', $result);
$this->assertStringContainsString('jquery.js', $result);
}

Expand Down

0 comments on commit f9630f7

Please sign in to comment.