public function testRuleInsertion()
 {
     $sCss = '.wrapper { left: 10px; text-align: left; }';
     $oParser = new Parser($sCss);
     $oDoc = $oParser->parse();
     $aContents = $oDoc->getContents();
     $oWrapper = $aContents[0];
     $oFirst = $oWrapper->getRules('left');
     $this->assertCount(1, $oFirst);
     $oFirst = $oFirst[0];
     $oSecond = $oWrapper->getRules('text-');
     $this->assertCount(1, $oSecond);
     $oSecond = $oSecond[0];
     $oBefore = new Rule('left');
     $oBefore->setValue(new Size(16, 'em'));
     $oMiddle = new Rule('text-align');
     $oMiddle->setValue(new Size(1));
     $oAfter = new Rule('border-bottom-width');
     $oAfter->setValue(new Size(1, 'px'));
     $oWrapper->addRule($oAfter);
     $oWrapper->addRule($oBefore, $oFirst);
     $oWrapper->addRule($oMiddle, $oSecond);
     $aRules = $oWrapper->getRules();
     $this->assertSame($oBefore, $aRules[0]);
     $this->assertSame($oFirst, $aRules[1]);
     $this->assertSame($oMiddle, $aRules[2]);
     $this->assertSame($oSecond, $aRules[3]);
     $this->assertSame($oAfter, $aRules[4]);
     $this->assertSame('.wrapper {left: 16em;left: 10px;text-align: 1;text-align: left;border-bottom-width: 1px;}', $oDoc->render());
 }
示例#2
0
文件: Parser.php 项目: horde/horde
 private function parseRule()
 {
     $oRule = new Rule($this->parseIdentifier());
     $this->consumeWhiteSpace();
     $this->consume(':');
     $oValue = $this->parseValue(self::listDelimiterForRule($oRule->getRule()));
     $oRule->setValue($oValue);
     if ($this->comes('!')) {
         $this->consume('!');
         $this->consumeWhiteSpace();
         $this->consume('important');
         $oRule->setIsImportant(true);
     }
     while ($this->comes(';')) {
         $this->consume(';');
         $this->consumeWhiteSpace();
     }
     return $oRule;
 }
示例#3
0
文件: Parser.php 项目: janeklb/moodle
 private function parseRule()
 {
     $aComments = $this->consumeWhiteSpace();
     $oRule = new Rule($this->parseIdentifier(), $this->iLineNo);
     $oRule->setComments($aComments);
     $oRule->addComments($this->consumeWhiteSpace());
     $this->consume(':');
     $oValue = $this->parseValue(self::listDelimiterForRule($oRule->getRule()));
     $oRule->setValue($oValue);
     if ($this->oParserSettings->bLenientParsing) {
         while ($this->comes('\\')) {
             $this->consume('\\');
             $oRule->addIeHack($this->consume());
             $this->consumeWhiteSpace();
         }
     }
     if ($this->comes('!')) {
         $this->consume('!');
         $this->consumeWhiteSpace();
         $this->consume('important');
         $oRule->setIsImportant(true);
     }
     while ($this->comes(';')) {
         $this->consume(';');
     }
     return $oRule;
 }