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. (#4)
  • Loading branch information
terabytesoftw committed Jan 23, 2024
1 parent 0cc5c74 commit 82b2035
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 24 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 #4: Fix phpdoc, update `README.md`, clean tests, and update `styleci.yml` configuration (@terabytesoftw)

## 0.1.0 January 22, 2024

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<br>
</p>


<p align="center">
<a href="https://github.com/yii3-extensions/asset-flowbite/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii3-extensions/asset-flowbite/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
Expand Down Expand Up @@ -54,15 +53,15 @@ or add

[Check the documentation docs](/docs/README.md) to learn about usage.

## Testing

[Check the documentation testing](/docs/testing.md) to learn about testing.

## Support versions

[![PHP81](https://img.shields.io/badge/PHP-%3E%3D8.1-787CB5)](https://www.php.net/releases/8.1/en.php)
[![Yii30](https://img.shields.io/badge/Yii%20version-3.0-blue)](https://yiiframework.com)

## Testing

[Check the documentation testing](/docs/testing.md) to learn about testing.

## Our social networks

[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555?style=flat)](https://twitter.com/Terabytesoftw)
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 @@ -21,7 +24,7 @@ use Yii\Asset\Flowbite;
* @var \Yiisoft\Assets\AssetManager $assetManager
*/

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

// Set parameters for the registered asset bundle a view component.
Expand All @@ -32,7 +35,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
4 changes: 4 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ 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

Expand Down
5 changes: 4 additions & 1 deletion src/Flowbite.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Yiisoft\Assets\AssetBundle;
use Yiisoft\Files\PathMatcher\PathMatcher;

/**
* Flowbite CSS bundle.
*/
final class Flowbite extends AssetBundle
{
public string|null $basePath = '@assets';
Expand All @@ -24,7 +27,7 @@ public function __construct()
$this->css = [$cssFiles];
$this->js = [$jsFiles];
$this->publishOptions = [
'filter' => $pathMatcher->only("**/{$cssFiles}", "**/{$jsFiles}", "**/{$jsFiles}.map"),
'filter' => $pathMatcher->only("**/$cssFiles", "**/$jsFiles", "**/$jsFiles.map"),
];
}
}
3 changes: 3 additions & 0 deletions src/FlowbiteCdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Yiisoft\Assets\AssetBundle;

/**
* Flowbite CDN CSS bundle.
*/
final class FlowbiteCdn extends AssetBundle
{
public bool $cdn = true;
Expand Down
14 changes: 8 additions & 6 deletions tests/FlowbiteCdnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@

declare(strict_types=1);

namespace Yii\Asset\Tests\Css;
namespace Yii\Asset\Tests;

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

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

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

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

$this->assertTrue($this->assetManager->isRegisteredBundle(FlowbiteCdn::class));

$bundle = $this->assetManager->getBundle(FlowbiteCdn::class);

$this->assertInstanceOf(AssetBundle::class, $bundle);
$this->assertSame(
[
'https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.css' => [
Expand Down
17 changes: 13 additions & 4 deletions tests/FlowbiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,32 @@

declare(strict_types=1);

namespace Yii\Asset\Tests\Css;
namespace Yii\Asset\Tests;

use PHPUnit\Framework\Attributes\RequiresPhp;
use Yii\Asset\Flowbite;
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 FlowbiteTest extends \PHPUnit\Framework\TestCase
{
use TestSupport;

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

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

$this->assertInstanceOf(AssetBundle::class, $this->assetManager->getBundle(Flowbite::class));
$this->assertTrue($this->assetManager->isRegisteredBundle(Flowbite::class));
$this->assertSame(
[
'/55145ba9/flowbite.css' => ['/55145ba9/flowbite.css'],
Expand All @@ -42,6 +48,9 @@ public function testRegister(): void
$this->assertFileDoesNotExist(__DIR__ . '/Support/runtime/55145ba9/flowbite.min.js.map');
}

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

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

$this->assertInstanceOf(AssetBundle::class, $this->assetManager->getBundle(Flowbite::class));
$this->assertTrue($this->assetManager->isRegisteredBundle(Flowbite::class));
$this->assertSame(
[
'/55145ba9/flowbite.min.css' => ['/55145ba9/flowbite.min.css'],
Expand Down

0 comments on commit 82b2035

Please sign in to comment.