Skip to content

Commit

Permalink
[+]: update phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Moelleken committed Jun 9, 2022
1 parent 777f3b6 commit 2fb4181
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = true

[*]
indent_style = space
indent_size = 2
indent_size = 4
end_of_line = lf
charset = utf-8
#trim_trailing_whitespace = true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ composer.lock

# php (phpunit)
build/
.phpunit.result.cache

# php (phpcs fixer)
.php_cs.cache
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ext-dom": "*"
},
"require-dev": {
"phpunit/phpunit": "~6.0 || ~7.0"
"phpunit/phpunit": "~6.0 || ~7.0 || ~9.0"
},
"autoload": {
"psr-4": {
Expand Down
45 changes: 19 additions & 26 deletions tests/HtmlMinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ final class HtmlMinTest extends \PHPUnit\Framework\TestCase

public function testEmptyResult()
{
static::assertSame('', $this->compressor->minify(null));
static::assertSame('', $this->compressor->minify(' '));
static::assertSame('', $this->compressor->minify(''));
static::assertSame('', (new HtmlMin())->minify(null));
static::assertSame('', (new HtmlMin())->minify(' '));
static::assertSame('', (new HtmlMin())->minify(''));
}

/**
Expand Down Expand Up @@ -200,45 +200,36 @@ public function providerTrim(): array
],
];
}

protected function setUp()
{
parent::setUp();
$this->compressor = new HtmlMin();
}

protected function tearDown()
{
$this->compressor = null;
}


/**
* @dataProvider providerBoolAttr
*
* @param $input
*/
public function testBoolAttr($input)
{
$minifier = new HtmlMin();

$html = '<!doctype html><html><body><form>' . $input . '</form></body></html>';
$expected = '<!DOCTYPE html><html><body><form><input autofocus checked type=checkbox></form>';

$actual = $this->compressor->minify($html);
$actual = $minifier->minify($html);
static::assertSame($expected, $actual);

// ---

$html = '<html><body><form>' . $input . '</form></body></html>';
$expected = '<html><body><form><input autofocus checked type=checkbox></form>';

$actual = $this->compressor->minify($html);
$actual = $minifier->minify($html);
static::assertSame($expected, $actual);

// ---

$html = '<form>' . $input . '</form>';
$expected = '<form><input autofocus checked type=checkbox></form>';

$actual = $this->compressor->minify($html);
$actual = $minifier->minify($html);
static::assertSame($expected, $actual);
}

Expand Down Expand Up @@ -1388,7 +1379,7 @@ public function testForBrokenHtml()
*/
public function testMultipleSpaces($input, $expected)
{
$actual = $this->compressor->minify($input);
$actual = (new HtmlMin())->minify($input);
static::assertSame($expected, $actual);
}

Expand All @@ -1400,7 +1391,7 @@ public function testMultipleSpaces($input, $expected)
*/
public function testNewLinesTabsReturns($input, $expected)
{
$actual = $this->compressor->minify($input);
$actual = (new HtmlMin())->minify($input);
static::assertSame($expected, $actual);
}

Expand All @@ -1412,7 +1403,7 @@ public function testNewLinesTabsReturns($input, $expected)
*/
public function testSpaceAfterGt($input, $expected)
{
$actual = $this->compressor->minify($input);
$actual = (new HtmlMin())->minify($input);
static::assertSame($expected, $actual);
}

Expand All @@ -1424,7 +1415,7 @@ public function testSpaceAfterGt($input, $expected)
*/
public function testSpaceBeforeLt($input, $expected)
{
$actual = $this->compressor->minify($input);
$actual = (new HtmlMin())->minify($input);
static::assertSame($expected, $actual, 'tested: ' . $input);
}

Expand All @@ -1436,7 +1427,7 @@ public function testSpaceBeforeLt($input, $expected)
*/
public function testSpecialCharacterEncoding($input, $expected)
{
$actual = $this->compressor->minify($input, true);
$actual = (new HtmlMin())->minify($input, true);
static::assertSame($expected, $actual);
}

Expand All @@ -1448,13 +1439,15 @@ public function testSpecialCharacterEncoding($input, $expected)
*/
public function testTrim($input, $expected)
{
$actual = $this->compressor->minify($input);
$actual = (new HtmlMin())->minify($input);
static::assertSame($expected, $actual);
}

public function testDoRemoveCommentsWithFalse()
{
$this->compressor->doRemoveComments(false);
$minifier = new HtmlMin();

$minifier->doRemoveComments(false);

$html = <<<'HTML'
<!DOCTYPE html>
Expand All @@ -1473,7 +1466,7 @@ public function testDoRemoveCommentsWithFalse()

HTML;

$actual = $this->compressor->minify($html);
$actual = $minifier->minify($html);

$expectedHtml = <<<'HTML'
<!DOCTYPE html><html><head><title>Test</title> <body><!-- do not remove comment --> <hr> <!--
Expand Down

0 comments on commit 2fb4181

Please sign in to comment.