/usr/share/php/Horde/Css/Parser/vendor/sabberworm/php-css-parser/tests/Sabberworm/CSS/RuleSet/LenientParsingTest.php is in php-horde-css-parser 1.0.8-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <?php
namespace Sabberworm\CSS\RuleSet;
use Sabberworm\CSS\Parser;
use Sabberworm\CSS\Settings;
class LenientParsingTest extends \PHPUnit_Framework_TestCase {
/**
* @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
*/
public function testFaultToleranceOff() {
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-fault-tolerance.css";
$oParser = new Parser(file_get_contents($sFile), Settings::create()->beStrict());
$oParser->parse();
}
public function testFaultToleranceOn() {
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-fault-tolerance.css";
$oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true));
$oResult = $oParser->parse();
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 2000000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}', $oResult->render());
}
/**
* @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
*/
public function testEndToken() {
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-end-token.css";
$oParser = new Parser(file_get_contents($sFile), Settings::create()->beStrict());
$oParser->parse();
}
/**
* @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
*/
public function testEndToken2() {
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-end-token-2.css";
$oParser = new Parser(file_get_contents($sFile), Settings::create()->beStrict());
$oParser->parse();
}
public function testEndTokenPositive() {
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-end-token.css";
$oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true));
$oResult = $oParser->parse();
$this->assertSame("", $oResult->render());
}
public function testEndToken2Positive() {
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-end-token-2.css";
$oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true));
$oResult = $oParser->parse();
$this->assertSame('#home .bg-layout {background-image: url("/bundles/main/img/bg1.png?5");}', $oResult->render());
}
public function testLocaleTrap() {
setlocale(LC_ALL, "pt_PT", "no");
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-fault-tolerance.css";
$oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true));
$oResult = $oParser->parse();
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 2000000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}', $oResult->render());
}
public function testCaseInsensitivity() {
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "case-insensitivity.css";
$oParser = new Parser(file_get_contents($sFile));
$oResult = $oParser->parse();
$this->assertSame('@charset "utf-8";
@import url("test.css");
@media screen {}
#myid {case: insensitive !important;frequency: 30Hz;font-size: 1em;color: #ff0;color: hsl(40,40%,30%);font-family: Arial;}', $oResult->render());
}
}
|