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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"issues": "https://github.com/neilime/php-css-lint/issues"
},
"require": {
"php": "^7.3",
"php": "^7.3 || ^8",
"ext-json": "*"
},
"require-dev": {
Expand Down
37 changes: 29 additions & 8 deletions tests/TestSuite/LinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ class LinterTest extends \PHPUnit\Framework\TestCase
*/
protected $linter;

/**
* @var string
*/
protected $phpVersion;

protected function setUp(): void
{
$this->linter = new \CssLint\Linter();
$php_version = phpversion();
if (version_compare($php_version, '8.0.0', '>=')) {
$this->phpVersion = '8';
} else {
$this->phpVersion = '7';
}
}

public function testConstructWithCustomCssLintProperties()
Expand Down Expand Up @@ -113,20 +124,30 @@ public function testLintStringWithWrongSelectorUnexpectedToken()
public function testLintStringWithWrongTypeParam()
{
$this->expectException(\TypeError::class);
$this->expectExceptionMessage(
'Argument 1 passed to CssLint\Linter::lintString() must be of the type string, array given'
);

if ($this->phpVersion == '8') {
$this->expectExceptionMessage(
'CssLint\Linter::lintString(): Argument #1 ($sString) must be of type string, array given'
);
} else {
$this->expectExceptionMessage(
'Argument 1 passed to CssLint\Linter::lintString() must be of the type string, array given'
);
}
$this->linter->lintString(['wrong']);
$this->assertFalse(false);
}

public function testLintFileWithWrongTypeParam()
{
$this->expectException(\TypeError::class);
$this->expectExceptionMessage(
'Argument 1 passed to CssLint\Linter::lintFile() must be of the type string, array given'
);
if ($this->phpVersion == '8') {
$this->expectExceptionMessage(
'CssLint\Linter::lintFile(): Argument #1 ($sFilePath) must be of type string, array given'
);
} else {
$this->expectExceptionMessage(
'Argument 1 passed to CssLint\Linter::lintFile() must be of the type string, array given'
);
}
$this->linter->lintFile(['wrong']);
}

Expand Down