Skip to content

Commit 152b196

Browse files
committed
Refactor tests to framework verison
1 parent a811390 commit 152b196

File tree

14 files changed

+61
-89
lines changed

14 files changed

+61
-89
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
build/
33
phpunit*.xml
44
phpunit
5+
*.cache
56
composer.lock
67
.DS_Store

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Tatter\Assets
2+
23
Lightweight asset loader for CodeIgniter 4
34

5+
[![](https://github.com/tattersoftware/codeigniter4-assets/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-assets/actions?query=workflow%3A%22PHPUnit)
6+
47
## Quick Start
58

69
1. Install with Composer: `> composer require tatter/assets`

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626
}
2727
],
2828
"minimum-stability": "dev",
29+
"prefer-stable": true,
2930
"require": {
3031
"php" : ">=7.2"
3132
},
3233
"require-dev": {
3334
"codeigniter4/codeigniter4": "dev-develop",
35+
"fzaninotto/faker": "^1.9@dev",
3436
"mikey179/vfsstream": "1.6.*",
35-
"mockery/mockery": "^1.0",
36-
"phpunit/phpunit" : "^7.0"
37+
"phpunit/phpunit" : "^8.5"
3738
},
3839
"autoload": {
3940
"psr-4": {
@@ -42,7 +43,7 @@
4243
},
4344
"autoload-dev": {
4445
"psr-4": {
45-
"ModuleTests\\Support\\": "tests/_support"
46+
"Tests\\Support\\": "tests/_support"
4647
}
4748
},
4849
"scripts": {

src/Handlers/ConfigHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use CodeIgniter\Config\BaseConfig;
44
use Config\Services;
5+
use Tatter\Assets\Exceptions\AssetsException;
56
use Tatter\Assets\Handlers\DirectoryHandler;
67
use Tatter\Assets\Interfaces\AssetHandlerInterface;
78

tests/_support/AssetsTestCase.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
<?php namespace ModuleTests\Support;
1+
<?php namespace Tests\Support;
22

3-
class AssetsTestCase extends \CodeIgniter\Test\CIUnitTestCase
3+
use CodeIgniter\Test\CIUnitTestCase;
4+
use Tatter\Assets\Libraries\Assets;
5+
6+
class AssetsTestCase extends CIUnitTestCase
47
{
58
/**
69
* @var \Tatter\Assets\Libraries\Assets
@@ -16,11 +19,11 @@ public function setUp(): void
1619
{
1720
parent::setUp();
1821

19-
$this->config = new \Tatter\Assets\Config\Assets;
22+
$this->config = new \Tatter\Assets\Config\Assets();
2023
$this->config->silent = false;
21-
$this->config->fileBase = MODULESUPPORTPATH . 'assets/';
24+
$this->config->fileBase = SUPPORTPATH . 'assets/';
2225

2326
// Create the service
24-
$this->assets = new \Tatter\Assets\Libraries\Assets($this->config);
27+
$this->assets = new Assets($this->config);
2528
}
2629
}

tests/_support/ManifestsTestCase.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?php namespace ModuleTests\Support;
1+
<?php namespace Tests\Support;
22

3+
use CodeIgniter\Test\CIUnitTestCase;
4+
use Tatter\Assets\Libraries\Manifests;
35
use org\bovigo\vfs\vfsStream;
46

5-
class ManifestsTestCase extends \CodeIgniter\Test\CIUnitTestCase
7+
class ManifestsTestCase extends CIUnitTestCase
68
{
79
/**
810
* @var \Tatter\Assets\Libraries\Manifests
@@ -21,13 +23,13 @@ public function setUp(): void
2123
// Start the virtual filesystem
2224
$this->root = vfsStream::setup();
2325

24-
$this->config = new \Tatter\Assets\Config\Assets;
26+
$this->config = new \Tatter\Assets\Config\Assets();
2527
$this->config->silent = false;
2628
$this->config->fileBase = $this->root->url() . '/assets/';
27-
$this->config->publishBase = MODULESUPPORTPATH;
29+
$this->config->publishBase = SUPPORTPATH;
2830

2931
// Create the service
30-
$this->manifests = new \Tatter\Assets\Libraries\Manifests($this->config);
32+
$this->manifests = new Manifests($this->config);
3133

3234
// Create an example manifest (equivalent to Widgets.json)
3335
$this->testManifest = (object)[

tests/_support/assets/vendor/widget/colorful.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
backgorund-color: black;
3+
}

tests/_support/bootstrap.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

tests/assets/ConfigHandlerTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?php
22

3-
class ConfigHandlerTest extends \CodeIgniter\Test\CIUnitTestCase
3+
use CodeIgniter\Test\CIUnitTestCase;
4+
use Tatter\Assets\Handlers\ConfigHandler;
5+
use Tatter\Assets\Libraries\Assets;
6+
7+
class ConfigHandlerTest extends CIUnitTestCase
48
{
59
/**
610
* @var \Tatter\Assets\Libraries\Assets
@@ -16,9 +20,9 @@ public function setUp(): void
1620
{
1721
parent::setUp();
1822

19-
$this->config = new \Tatter\Assets\Config\Assets;
23+
$this->config = new \Tatter\Assets\Config\Assets();
2024
$this->config->silent = false;
21-
$this->config->fileBase = MODULESUPPORTPATH . 'assets/';
25+
$this->config->fileBase = SUPPORTPATH . 'assets/';
2226

2327
// Add mock route paths
2428
$this->config->routes = [
@@ -31,10 +35,10 @@ public function setUp(): void
3135
];
3236

3337
// Create the service
34-
$this->assets = new \Tatter\Assets\Libraries\Assets($this->config);
38+
$this->assets = new Assets($this->config);
3539

3640
// Limit to just the ConfigHandler
37-
$this->assets->setHandlers(['\Tatter\Assets\Handlers\ConfigHandler']);
41+
$this->assets->setHandlers([ConfigHandler::class]);
3842
}
3943

4044
public function testBasicRoute()
@@ -56,8 +60,8 @@ public function testRouteWithDirectory()
5660

5761
$expected = [
5862
'unrouted/machines.js',
59-
'vendor/widget/colorful.css',
6063
'vendor/widget/forms.css',
64+
'vendor/widget/colorful.css',
6165
];
6266

6367
$paths = $this->assets->getPaths();

0 commit comments

Comments
 (0)