/** * **/ public function testMergeDeclarations() { $sFile = __DIR__ . '/files/merge.css'; $oParser = new CSSParser(); $oDoc = $oParser->parseString(file_get_contents($sFile)); $aDeclarations = $oDoc->getAllDeclarationBlocks(); $oMerged = CSSDocument::mergeDeclarations($aDeclarations); $sExpected = "{color: rgb(255,0,0);background: rgb(0,255,255) none repeat-x 0% 0% scroll;margin: 0 0 1em;}"; $this->assertEquals(trim($oMerged->__toString()), $sExpected); }
/** * @dataProvider testMSFiltersProvider **/ public function testMSFilters($sCss, $sExpected) { $oParser = new CSSParser(); $oDoc = $oParser->parseString($sCss); $this->assertEquals((string) $oDoc, $sExpected); }
/** * @dataProvider expandCreateShorthandsProvider * * @depends testExpandBorderShorthand * @depends testExpandDimensionsShorthand * @depends testExpandBackgroundShorthand * @depends testExpandFontShorthand * @depends testCreateBorderShorthand * @depends testCreateDimensionsShorthand * @depends testCreateBackgroundShorthand * @depends testCreateFontShorthand **/ public function testExpandCreateShorthands($sCss, $sExpected) { $oParser = new CSSParser(); $oDoc = $oParser->parseString($sCss); $oDoc->expandShorthands(); $oDoc->createShorthands(); $this->assertEquals((string) $oDoc, $sExpected); }
function parsedStructureForFile($sFileName) { $sFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . "{$sFileName}.css"; $oParser = new CSSParser(); return $oParser->parseString(file_get_contents($sFile)); }
/** * @dataProvider testAbsoluteUrlsProvider **/ public function testAbsoluteUrls($sCSS, $sBaseUrl, $sExpected) { $parser = new CSSParser(array('absolute_urls' => true, 'base_url' => $sBaseUrl)); $oDoc = $parser->parseString($sCSS); $this->assertEquals($oDoc->__toString(), $sExpected); }