Skip to content

Commit

Permalink
Remove popper. (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw authored Nov 23, 2023
1 parent c5e43b3 commit 7d8d769
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 155 deletions.
32 changes: 7 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a href="https://github.com/yii2-extensions/asset-bootstrap5" target="_blank">
<img src="https://www.yiiframework.com/image/yii_logo_light.svg" height="100px;">
</a>
<h1 align="center">Asset for Twitter Bootstrap 5.</h1>
<h1 align="center">Asset bundle for Twitter Bootstrap 5.</h1>
<br>
</p>

Expand Down Expand Up @@ -42,7 +42,7 @@ or add

to the require-dev section of your `composer.json` file.

## Usage
## Basic usage

```php
<?php
Expand All @@ -59,49 +59,31 @@ BootstrapAsset::register($this);

declare(strict_types=1);

use Yii2\Asset\BootstrapCdnAsset;

BootstrapCdnAsset::register($this);
```

```php
<?php

declare(strict_types=1);

use Yii2\Asset\BootstrapPluginAsset;

BootstrapPluginAsset::register($this);
```

```php
<?php

declare(strict_types=1);

use Yii2\Asset\BootstrapPluginCdnAsset;

BootstrapPluginCdnAsset::register($this);
```
## CDN usage

```php
<?php

declare(strict_types=1);

use Yii2\Asset\PopperAsset;
use Yii2\Asset\BootstrapCdnAsset;

PopperAsset::register($this);
BootstrapCdnAsset::register($this);
```

```php
<?php

declare(strict_types=1);

use Yii2\Asset\PopperCdnAsset;
use Yii2\Asset\BootstrapPluginCdnAsset;

PopperCdnAsset::register($this);
BootstrapPluginCdnAsset::register($this);
```

## Quality code
Expand Down
3 changes: 2 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
includes:
- vendor/yii2-extensions/phpstan/extension.neon

parameters:
bootstrapFiles:
- tests/bootstrap.php
- tests/Support/bootstrap.php

dynamicConstantNames:
- YII_ENV
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="tests/bootstrap.php"
bootstrap="tests/Support/bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
executionOrder="depends,defects"
Expand Down
29 changes: 0 additions & 29 deletions src/PopperAsset.php

This file was deleted.

32 changes: 0 additions & 32 deletions src/PopperCdnAsset.php

This file was deleted.

63 changes: 0 additions & 63 deletions tests/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Yii2\Asset\BootstrapCdnAsset;
use Yii2\Asset\BootstrapPluginAsset;
use Yii2\Asset\BootstrapPluginCdnAsset;
use Yii2\Asset\PopperAsset;
use Yii2\Asset\PopperCdnAsset;
use yii\web\AssetBundle;
use yii\web\View;

Expand Down Expand Up @@ -150,65 +148,4 @@ public function testBootstrapPluginCdnAssetRegister(): void
$result,
);
}

public function testPopperAssetSimpleDependency(): void
{
$view = Yii::$app->getView();

$this->assertEmpty($view->assetBundles);

PopperAsset::register($view);

$this->assertCount(1, $view->assetBundles);
$this->assertArrayHasKey(PopperAsset::class, $view->assetBundles);
}

public function testPopperAssetRegister(): void
{
$view = new View();

$this->assertEmpty($view->assetBundles);

PopperAsset::register($view);

$this->assertCount(1, $view->assetBundles);
$this->assertInstanceOf(AssetBundle::class, $view->assetBundles[PopperAsset::class]);

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

$this->assertStringContainsString('popper.js', $result);
}

public function testPopperCdnAssetSimpleDependency(): void
{
$view = Yii::$app->getView();

$this->assertEmpty($view->assetBundles);

PopperCdnAsset::register($view);

$this->assertCount(1, $view->assetBundles);
$this->assertArrayHasKey(PopperCdnAsset::class, $view->assetBundles);
}

public function testPopperCdnAssetRegister(): void
{
$view = new View();

$this->assertEmpty($view->assetBundles);

PopperCdnAsset::register($view);

$this->assertCount(1, $view->assetBundles);
$this->assertInstanceOf(AssetBundle::class, $view->assetBundles[PopperCdnAsset::class]);

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

$this->assertStringContainsString(
<<<HTML
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" crossorigin="anonymous" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"></script>
HTML,
$result,
);
}
}
7 changes: 3 additions & 4 deletions tests/bootstrap.php → tests/Support/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

define('YII_ENV', 'test');

$autoload = dirname(__DIR__) . '/vendor/autoload.php';
$yii2 = dirname(__DIR__) . '/vendor/yiisoft/yii2/Yii.php';
$root = dirname(__DIR__, 2);
$autoload = $root . '/vendor/autoload.php';
$yii2 = $root . '/vendor/yiisoft/yii2/Yii.php';

if (!is_file($autoload)) {
die('You need to set up the project dependencies using Composer');
Expand All @@ -17,5 +18,3 @@

require_once $autoload;
require_once $yii2;

Yii::setAlias('@root', dirname(__DIR__));

0 comments on commit 7d8d769

Please sign in to comment.