Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: HTMLMinTests
on: [push, pull_request]
on: [push]
jobs:
htmlmin:
name: PHP ${{ matrix.php-versions }}
Expand Down Expand Up @@ -33,4 +33,3 @@ jobs:
env:
PHP_VERSION: ${{ matrix.php-versions }}
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml
continue-on-error: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
composer.lock
phpunit.xml
vendor
/.idea
/.idea
/.phpunit.cache
39 changes: 11 additions & 28 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="Laravel HTMLMin Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Laravel HTMLMin Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/HTMLMinServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function registerMinifyCompiler()
$storagePath = $app->config->get('view.compiled');
$ignoredPaths = $app->config->get('htmlmin.ignore', []);

return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $this->previousCompiler, $this->previousCompiler->getCustomDirectives());
return new MinifyCompiler($blade, $files, $storagePath, $ignoredPaths, $this->previousCompiler, $this->previousCompiler?->getCustomDirectives() ?? []);
});

$this->app->alias('htmlmin.compiler', MinifyCompiler::class);
Expand Down
9 changes: 1 addition & 8 deletions tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@
*/
abstract class AbstractTestCase extends AbstractPackageTestCase
{
/**
* Get the service provider class.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return string
*/
protected function getServiceProviderClass()
protected static function getServiceProviderClass(): string
{
return HTMLMinServiceProvider::class;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Compilers/MinifyCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
*
* @author Graham Campbell <graham@alt-three.com>
*/
class MinifyCompilerTest extends AbstractTestCase
final class MinifyCompilerTest extends AbstractTestCase
{
public function testMinify()
public function testMinify(): void
{
$compiler = $this->getCompiler();

Expand All @@ -37,7 +37,7 @@ public function testMinify()
$this->assertSame('abc', $return);
}

public function testMinifyIgnored()
public function testMinifyIgnored(): void
{
$blade = Mockery::mock(BladeMinifier::class);
$files = Mockery::mock(Filesystem::class);
Expand All @@ -57,7 +57,7 @@ public function testMinifyIgnored()
$this->assertSame($html, $return);
}

public function testCompilers()
public function testCompilers(): void
{
$compiler = $this->getCompiler();

Expand Down
12 changes: 3 additions & 9 deletions tests/Facades/HTMLMinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,24 @@ class HTMLMinTest extends AbstractTestCase

/**
* Get the facade accessor.
*
* @return string
*/
protected function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return 'htmlmin';
}

/**
* Get the facade class.
*
* @return string
*/
protected function getFacadeClass()
protected static function getFacadeClass(): string
{
return Facade::class;
}

/**
* Get the facade root.
*
* @return string
*/
protected function getFacadeRoot()
protected static function getFacadeRoot(): string
{
return HTMLMin::class;
}
Expand Down
8 changes: 3 additions & 5 deletions tests/Functional/BladeEnabledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@
*
* @author Graham Campbell <graham@alt-three.com>
*/
class BladeEnabledTest extends AbstractFunctionalTestCase
final class BladeEnabledTest extends AbstractFunctionalTestCase
{
/**
* Setup the application environment.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

$app->config->set('htmlmin.blade', true);
}

public function testNewSetup()
public function testNewSetup(): void
{
$this->app->view->addNamespace('stubs', realpath(__DIR__.'/stubs'));

Expand Down
8 changes: 3 additions & 5 deletions tests/Functional/ComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
use HTMLMin\HTMLMin\Compilers\MinifyCompiler;
use HTMLMin\Tests\HTMLMin\Functional\Provider\TestComponentsProvider;

class ComponentsTest extends AbstractFunctionalTestCase
final class ComponentsTest extends AbstractFunctionalTestCase
{
/**
* Get the required service providers.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return string[]
*/
protected function getRequiredServiceProviders($app)
protected static function getRequiredServiceProviders(): array
{
return [TestComponentsProvider::class];
}

public function testUseComponents()
public function testUseComponents(): void
{
if (version_compare($this->app->version(), '7.0', '<')) {
$this->markTestSkipped('Class components were released in Laravel version 7.0.0');
Expand Down
8 changes: 3 additions & 5 deletions tests/Functional/DirectivesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@
use HTMLMin\Tests\HTMLMin\Functional\Provider\TestDirectivesProvider;
use HTMLMin\Tests\HTMLMin\Mock\MinifyCompilerMock;

class DirectivesTest extends AbstractFunctionalTestCase
final class DirectivesTest extends AbstractFunctionalTestCase
{
/**
* Get the required service providers.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return string[]
*/
protected function getRequiredServiceProviders($app)
protected static function getRequiredServiceProviders(): array
{
return [TestDirectivesProvider::class];
}

public function testUseDirectives()
public function testUseDirectives(): void
{
/** @var MinifyCompiler $minifyCompiler */
$minifyCompiler = $this->app->make('view')
Expand Down
12 changes: 5 additions & 7 deletions tests/Functional/MiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,21 @@
*
* @author Graham Campbell <graham@alt-three.com>
*/
class MiddlewareTest extends AbstractFunctionalTestCase
final class MiddlewareTest extends AbstractFunctionalTestCase
{
/**
* Setup the application environment.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

$app->config->set('htmlmin.live', true);
}

public function testNewSetup()
public function testNewSetup(): void
{
$this->app->view->addNamespace('stubs', realpath(__DIR__.'/stubs'));

Expand All @@ -53,7 +51,7 @@ public function testNewSetup()
$this->assertSameIgnoreLineEndings($expected, $actual);
}

public function testRedirect()
public function testRedirect(): void
{
$this->app->router->get('htmlmin-test-route', ['middleware' => MinifyMiddleware::class, function () {
return Redirect::to('foo');
Expand All @@ -64,7 +62,7 @@ public function testRedirect()
$this->assertSame($this->app->url->to('foo'), $response->headers->get('Location'));
}

public function testJson()
public function testJson(): void
{
$this->app->router->get('htmlmin-test-route', ['middleware' => MinifyMiddleware::class, function () {
return Response::json(['foo' => 'bar', ['baz']], 200, [], JSON_PRETTY_PRINT);
Expand Down
5 changes: 2 additions & 3 deletions tests/Functional/Provider/TestDirectivesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;

class TestDirectivesProvider extends ServiceProvider
final class TestDirectivesProvider extends ServiceProvider
{
public static function testDirective()
public static function testDirective(): void
{
return 'test content';
}

public function register()
Expand Down
10 changes: 4 additions & 6 deletions tests/Functional/SkipMinificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,23 @@
*
* @author Graham Campbell <graham@alt-three.com>
*/
class SkipMinificationTest extends AbstractFunctionalTestCase
final class SkipMinificationTest extends AbstractFunctionalTestCase
{
/**
* Setup the application environment.
*
* Ensure that blade is on.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*
* @return void
*/
protected function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

$app->config->set('htmlmin.blade', true);
}

public function testNewSkipHMTL()
public function testNewSkipHMTL(): void
{
$this->app->view->addNamespace('stubs', realpath(__DIR__.'/stubs'));

Expand All @@ -48,7 +46,7 @@ public function testNewSkipHMTL()
$this->assertSameIgnoreLineEndings($expected, $actual);
}

public function testMarkDown()
public function testMarkDown(): void
{
$this->app->view->addNamespace('stubs', realpath(__DIR__.'/stubs'));

Expand Down
11 changes: 5 additions & 6 deletions tests/HTMLMinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace HTMLMin\Tests\HTMLMin;

use PHPUnit\Framework\Attributes\DataProvider;
use GrahamCampbell\TestBench\AbstractTestCase as AbstractTestBenchTestCase;
use HTMLMin\HTMLMin\HTMLMin;
use HTMLMin\HTMLMin\Minifiers\BladeMinifier;
Expand All @@ -25,9 +26,9 @@
*
* @author Graham Campbell <graham@alt-three.com>
*/
class HTMLMinTest extends AbstractTestBenchTestCase
final class HTMLMinTest extends AbstractTestBenchTestCase
{
public function methodProvider()
public static function methodProvider(): array
{
return [
['blade', 'getBladeMinifier'],
Expand All @@ -37,10 +38,8 @@ public function methodProvider()
];
}

/**
* @dataProvider methodProvider
*/
public function testMethods($method, $class)
#[DataProvider('methodProvider')]
public function testMethods($method, $class): void
{
$htmlmin = $this->getHTMLMin();

Expand Down
Loading
Loading