Skip to content

Commit

Permalink
Fix phpdoc, update README.md, clean tests, and update styleci.yml
Browse files Browse the repository at this point in the history
… configuration. (#22)
  • Loading branch information
terabytesoftw committed Jan 23, 2024
1 parent a713f46 commit a735e75
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 46 deletions.
7 changes: 4 additions & 3 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ enabled:
- combine_nested_dirname
- declare_strict_types
- dir_constant
- empty_loop_body_braces
- fully_qualified_strict_types
- function_to_constant
- hash_to_slash_comment
- integer_literal_case
- is_null
- logical_operators
- magic_constant_casing
Expand Down Expand Up @@ -56,7 +58,6 @@ enabled:
- phpdoc_order
- phpdoc_property
- phpdoc_scalar
- phpdoc_separation
- phpdoc_singular_inheritdoc
- phpdoc_trim
- phpdoc_trim_consecutive_blank_line_separation
Expand All @@ -78,9 +79,9 @@ enabled:
- trailing_comma_in_multiline_array
- unalign_double_arrow
- unalign_equals
- empty_loop_body_braces
- integer_literal_case
- union_type_without_spaces

disabled:
- function_declaration
- psr12_braces
- psr12_class_definition
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Change Log
==========

## 0.1.1 Under development
## 0.1.1 January 23, 2024

- Bug #22: Fix phpdoc, update `README.md`, clean tests, and update `styleci.yml` configuration (@terabytesoftw)

## 0.1.0 January 21, 2024

Expand Down
11 changes: 7 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Using assets

Assets are files that are not processed by Webpack. They are copied directly to the output folder. This includes images,
fonts, and any other files that you want to use in your project.
Assets are files that Webpack does not process.

They are copied directly to the output folder.

This includes images, fonts, and any other files that you want to use in your project.

To use an asset, you need to import it from JavaScript or CSS.

Expand All @@ -22,7 +25,7 @@ use Yiisoft\Assets\AssetManager;
* @var AssetManager $assetManager
*/

// Register the asset bundle with a asset manager component.
// Register the asset bundle with an asset manager component.
$assetManager->register(BootstrapAsset::class);

// Set parameters for the registered asset bundle a view component.
Expand All @@ -33,7 +36,7 @@ $this->addJsStrings($assetManager->getJsStrings());
$this->addJsVars($assetManager->getJsVars());
```

Also you can register the asset bundle via container configuration:
Also, you can register the asset bundle via container configuration:

```php
file: ./config/params.php
Expand Down
8 changes: 7 additions & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

## Checking dependencies

This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`.
This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all
dependencies are correctly defined in `composer.json`.

To run the checker, execute the following command:

```shell
composer run check-dependencies
```

## Easy coding standard

The code is checked with [Easy Coding Standard](https://github.com/easy-coding-standard/easy-coding-standard) and
[PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer). To run it:

## Mutation testing

Mutation testing is checked with [Infection](https://infection.github.io/). To run it:
Expand Down
38 changes: 19 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="tests/Support/bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
executionOrder="depends,defects"
failOnRisky="true"
failOnWarning="true"
stopOnFailure="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="tests/Support/bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
executionOrder="depends,defects"
failOnRisky="true"
failOnWarning="true"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Asset-Bootstrap5">
<directory>tests</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="Asset-Bootstrap5">
<directory>tests</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/BootstrapAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function defined;

/**
* Twitter Bootstrap 5 CSS bundle.
* Twitter Bootstrap5 CSS bundle.
*/
final class BootstrapAsset extends AssetBundle
{
Expand All @@ -27,7 +27,7 @@ public function __construct()

$this->css = [$cssFiles];
$this->publishOptions = [
'filter' => $pathMatcher->only("**/css/{$cssFiles}", "**/css/{$cssFiles}.map"),
'filter' => $pathMatcher->only("**/css/$cssFiles", "**/css/$cssFiles.map"),
];
}
}
2 changes: 1 addition & 1 deletion src/BootstrapCdnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Assets\AssetBundle;

/**
* Twitter Bootstrap 5 CDN CSS bundle.
* Twitter Bootstrap5 CDN CSS bundle.
*/
final class BootstrapCdnAsset extends AssetBundle
{
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapPluginAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use function defined;

/**
* Twitter Bootstrap 5 JavaScript bundle.
* Twitter Bootstrap5 JavaScript bundle.
*/
final class BootstrapPluginAsset extends AssetBundle
{
Expand All @@ -28,7 +28,7 @@ public function __construct()

$this->js = [$jsFiles];
$this->publishOptions = [
'filter' => $pathMatcher->only("**/js/{$jsFiles}", "**/js/{$jsFiles}.map"),
'filter' => $pathMatcher->only("**/js/$jsFiles", "**/js/$jsFiles.map"),
];
}
}
2 changes: 1 addition & 1 deletion src/BootstrapPluginCdnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Assets\AssetBundle;

/**
* Twitter Bootstrap 5 CDN JavaScript bundle.
* Twitter Bootstrap5 CDN JavaScript bundle.
*/
final class BootstrapPluginCdnAsset extends AssetBundle
{
Expand Down
16 changes: 13 additions & 3 deletions tests/BootstrapAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@
use PHPUnit\Framework\Attributes\RequiresPhp;
use Yii\Asset\BootstrapAsset;
use Yii\Asset\Tests\Support\TestSupport;
use Yiisoft\Assets\AssetBundle;

use Yiisoft\Assets\Exception\InvalidConfigException;

use function runkit_constant_redefine;

/**
* @psalm-suppress PropertyNotSetInConstructor
*/
final class BootstrapAssetTest extends \PHPUnit\Framework\TestCase
{
use TestSupport;

/**
* @throws InvalidConfigException
*/
public function testRegister(): void
{
$this->assertFalse($this->assetManager->isRegisteredBundle(BootstrapAsset::class));

$this->assetManager->register(BootstrapAsset::class);

$this->assertInstanceOf(AssetBundle::class, $this->assetManager->getBundle(BootstrapAsset::class));
$this->assertTrue($this->assetManager->isRegisteredBundle(BootstrapAsset::class));
$this->assertSame(
[
'/55145ba9/bootstrap.css' => ['/55145ba9/bootstrap.css'],
Expand All @@ -32,6 +39,9 @@ public function testRegister(): void
$this->assertFileExists(__DIR__ . '/Support/runtime/55145ba9/bootstrap.css.map');
}

/**
* @throws InvalidConfigException
*/
#[RequiresPhp('8.1')]
public function testRegisterWithEnvironmentProd(): void
{
Expand All @@ -41,7 +51,7 @@ public function testRegisterWithEnvironmentProd(): void

$this->assetManager->register(BootstrapAsset::class);

$this->assertInstanceOf(AssetBundle::class, $this->assetManager->getBundle(BootstrapAsset::class));
$this->assertTrue($this->assetManager->isRegisteredBundle(BootstrapAsset::class));
$this->assertSame(
[
'/55145ba9/bootstrap.min.css' => ['/55145ba9/bootstrap.min.css'],
Expand Down
10 changes: 8 additions & 2 deletions tests/BootstrapCdnAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@

use Yii\Asset\BootstrapCdnAsset;
use Yii\Asset\Tests\Support\TestSupport;
use Yiisoft\Assets\AssetBundle;
use Yiisoft\Assets\Exception\InvalidConfigException;

/**
* @psalm-suppress PropertyNotSetInConstructor
*/
final class BootstrapCdnAssetTest extends \PHPUnit\Framework\TestCase
{
use TestSupport;

/**
* @throws InvalidConfigException
*/
public function testRegister(): void
{
$assetManager = $this->assetManager;
Expand All @@ -20,7 +26,7 @@ public function testRegister(): void

$assetManager->register(BootstrapCdnAsset::class);

$this->assertInstanceOf(AssetBundle::class, $assetManager->getBundle(BootstrapCdnAsset::class));
$this->assertTrue($assetManager->isRegisteredBundle(BootstrapCdnAsset::class));
$this->assertSame(
[
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css' => [
Expand Down
12 changes: 12 additions & 0 deletions tests/BootstrapPluginAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,27 @@
use PHPUnit\Framework\Attributes\RequiresPhp;
use Yii\Asset\BootstrapPluginAsset;
use Yii\Asset\Tests\Support\TestSupport;
use Yiisoft\Assets\Exception\InvalidConfigException;

use function runkit_constant_redefine;

/**
* @psalm-suppress PropertyNotSetInConstructor
*/
final class BootstrapPluginAssetTest extends \PHPUnit\Framework\TestCase
{
use TestSupport;

/**
* @throws InvalidConfigException
*/
public function testRegister(): void
{
$this->assertFalse($this->assetManager->isRegisteredBundle(BootstrapPluginAsset::class));

$this->assetManager->register(BootstrapPluginAsset::class);

$this->assertTrue($this->assetManager->isRegisteredBundle(BootstrapPluginAsset::class));
$this->assertSame(
[
'/55145ba9/bootstrap.css' => ['/55145ba9/bootstrap.css'],
Expand All @@ -43,6 +51,9 @@ public function testRegister(): void
$this->assertFileDoesNotExist(__DIR__ . '/Support/runtime/16b8de20/bootstrap.bundle.min.js.map');
}

/**
* @throws InvalidConfigException
*/
#[RequiresPhp('8.1')]
public function testRegisterWithEnvironmentProd(): void
{
Expand All @@ -52,6 +63,7 @@ public function testRegisterWithEnvironmentProd(): void

$this->assetManager->register(BootstrapPluginAsset::class);

$this->assertTrue($this->assetManager->isRegisteredBundle(BootstrapPluginAsset::class));
$this->assertSame(
[
'/55145ba9/bootstrap.min.css' => ['/55145ba9/bootstrap.min.css'],
Expand Down
8 changes: 8 additions & 0 deletions tests/BootstrapPluginCdnAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@

use Yii\Asset\BootstrapPluginCdnAsset;
use Yii\Asset\Tests\Support\TestSupport;
use Yiisoft\Assets\Exception\InvalidConfigException;

/**
* @psalm-suppress PropertyNotSetInConstructor
*/
final class BootstrapPluginCdnAssetTest extends \PHPUnit\Framework\TestCase
{
use TestSupport;

/**
* @throws InvalidConfigException
*/
public function testRegister(): void
{
$this->assertFalse($this->assetManager->isRegisteredBundle(BootstrapPluginCdnAsset::class));

$this->assetManager->register(BootstrapPluginCdnAsset::class);

$this->assertTrue($this->assetManager->isRegisteredBundle(BootstrapPluginCdnAsset::class));
$this->assertSame(
[
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css' => [
Expand Down
7 changes: 0 additions & 7 deletions tests/Support/main.php

This file was deleted.

0 comments on commit a735e75

Please sign in to comment.