Skip to content

Test enhancement #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ php:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- hhvm-3.30
sudo: false
dist: trusty
Expand All @@ -19,4 +20,3 @@ matrix:
before_script: rm composer.lock && composer install
script: ./vendor/bin/phpunit --coverage-clover build/coverage/xml
after_script: ./vendor/bin/codacycoverage clover build/coverage/xml

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"phpunit/phpunit": "^4.8.36",
"codacy/coverage": "^1.4"
},
"autoload": {
"psr-0": { "Sabberworm\\CSS\\": "lib/" }
"psr-4": { "Sabberworm\\CSS\\": "lib/Sabberworm/CSS/" }
}
}
6 changes: 6 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">lib/Sabberworm/CSS</directory>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion tests/Sabberworm/CSS/CSSList/AtRuleBlockListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Sabberworm\CSS\Parser;

class AtRuleBlockListTest extends \PHPUnit_Framework_TestCase {
class AtRuleBlockListTest extends \PHPUnit\Framework\TestCase {

public function testMediaQueries() {
$sCss = '@media(min-width: 768px){.class{color:red}}';
Expand Down
2 changes: 1 addition & 1 deletion tests/Sabberworm/CSS/CSSList/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Sabberworm\CSS\Parser;

class DocumentTest extends \PHPUnit_Framework_TestCase {
class DocumentTest extends \PHPUnit\Framework\TestCase {

public function testOverrideContents() {
$sCss = '.thing { left: 10px; }';
Expand Down
2 changes: 1 addition & 1 deletion tests/Sabberworm/CSS/OutputFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

EOT;

class OutputFormatTest extends \PHPUnit_Framework_TestCase {
class OutputFormatTest extends \PHPunit\Framework\TestCase {
private $oParser;
private $oDocument;

Expand Down
22 changes: 11 additions & 11 deletions tests/Sabberworm/CSS/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Sabberworm\CSS\Value\URL;
use Sabberworm\CSS\Parsing\UnexpectedTokenException;

class ParserTest extends \PHPUnit_Framework_TestCase {
class ParserTest extends \PHPunit\Framework\TestCase {

function testFiles() {
$sDirectory = dirname(__FILE__) . '/../../files';
Expand Down Expand Up @@ -214,23 +214,23 @@ function testManipulation() {
$this->assertSame('#header {margin: 10px 2em 1cm 2%;color: red !important;frequency: 30Hz;}
body {color: green;}', $oDoc->render());
}

function testRuleGetters() {
$oDoc = $this->parsedStructureForFile('values');
$aBlocks = $oDoc->getAllDeclarationBlocks();
$oHeaderBlock = $aBlocks[0];
$oBodyBlock = $aBlocks[1];
$aHeaderRules = $oHeaderBlock->getRules('background-');
$this->assertSame(2, count($aHeaderRules));
$this->assertCount(2, $aHeaderRules);
$this->assertSame('background-color', $aHeaderRules[0]->getRule());
$this->assertSame('background-color', $aHeaderRules[1]->getRule());
$aHeaderRules = $oHeaderBlock->getRulesAssoc('background-');
$this->assertSame(1, count($aHeaderRules));
$this->assertSame(true, $aHeaderRules['background-color']->getValue() instanceof \Sabberworm\CSS\Value\Color);
$this->assertCount(1, $aHeaderRules);
$this->assertTrue($aHeaderRules['background-color']->getValue() instanceof \Sabberworm\CSS\Value\Color);
$this->assertSame('rgba', $aHeaderRules['background-color']->getValue()->getColorDescription());
$oHeaderBlock->removeRule($aHeaderRules['background-color']);
$aHeaderRules = $oHeaderBlock->getRules('background-');
$this->assertSame(1, count($aHeaderRules));
$this->assertCount(1, $aHeaderRules);
$this->assertSame('green', $aHeaderRules[0]->getValue());
}

Expand Down Expand Up @@ -319,7 +319,7 @@ function testNamespaces() {
|test {gaga: 2;}';
$this->assertSame($sExpected, $oDoc->render());
}

function testInnerColors() {
$oDoc = $this->parsedStructureForFile('inner-color');
$sExpected = 'test {background: -webkit-gradient(linear,0 0,0 bottom,from(#006cad),to(hsl(202,100%,49%)));}';
Expand Down Expand Up @@ -359,21 +359,21 @@ function testListValueRemoval() {
$this->assertSame('@media screen {html {some: -test(val2);}}
#unrelated {other: yes;}', $oDoc->render());
}

/**
* @expectedException Sabberworm\CSS\Parsing\OutputException
*/
function testSelectorRemoval() {
$oDoc = $this->parsedStructureForFile('1readme');
$aBlocks = $oDoc->getAllDeclarationBlocks();
$oBlock1 = $aBlocks[0];
$this->assertSame(true, $oBlock1->removeSelector('html'));
$this->assertTrue($oBlock1->removeSelector('html'));
$sExpected = '@charset "utf-8";
@font-face {font-family: "CrassRoots";src: url("../media/cr.ttf");}
body {font-size: 1.6em;}';
$this->assertSame($sExpected, $oDoc->render());
$this->assertSame(false, $oBlock1->removeSelector('html'));
$this->assertSame(true, $oBlock1->removeSelector('body'));
$this->assertFalse($oBlock1->removeSelector('html'));
$this->assertTrue($oBlock1->removeSelector('body'));
// This tries to output a declaration block without a selector and throws.
$oDoc->render();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Sabberworm/CSS/RuleSet/DeclarationBlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Sabberworm\CSS\Rule\Rule;
use Sabberworm\CSS\Value\Size;

class DeclarationBlockTest extends \PHPUnit_Framework_TestCase {
class DeclarationBlockTest extends \PHPUnit\Framework\TestCase {

/**
* @dataProvider expandBorderShorthandProvider
Expand Down
2 changes: 1 addition & 1 deletion tests/Sabberworm/CSS/RuleSet/LenientParsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Sabberworm\CSS\Parser;
use Sabberworm\CSS\Settings;

class LenientParsingTest extends \PHPUnit_Framework_TestCase {
class LenientParsingTest extends \PHPUnit\Framework\TestCase {

/**
* @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
require $file;
return true;
}
});
});
1 change: 0 additions & 1 deletion tests/quickdump.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@
print $oDoc->render();

echo "\n```\n";