Esempio n. 1
0
 public function testInvalidColorSpecification()
 {
     try {
         $value = new ezcDocumentPcssStyleColorValue();
         $value->parse('something invalid');
         $this->fail('Expected ezcDocumentParserException.');
     } catch (ezcDocumentParserException $e) {
         /* Expected */
     }
 }
Esempio n. 2
0
 /**
  * Parse value string representation.
  *
  * Parse the string representation of the value into a usable
  * representation.
  * 
  * @param string $value 
  * @return ezcDocumentPcssStyleValue
  */
 public function parse($value)
 {
     $widthParser = new ezcDocumentPcssStyleMeasureValue();
     $styleParser = new ezcDocumentPcssStyleLineValue();
     $colorParser = new ezcDocumentPcssStyleColorValue();
     $regexp = '(^\\s*' . '(?:(?P<width>' . $widthParser->getRegularExpression() . ')\\s*)?' . '(?:(?P<style>' . $styleParser->getRegularExpression() . ')\\s*)?' . '(?:(?P<color>' . $colorParser->getRegularExpression() . ')\\s*)?' . '\\s*$)';
     if (!preg_match($regexp, $value, $match)) {
         throw new ezcDocumentParserException(E_PARSE, "Invalid border specification: " . $value);
     }
     $this->value = $this->defaultValue;
     if (isset($match['width']) && !empty($match['width'])) {
         $this->value['width'] = $widthParser->parse($match['width'])->value;
     }
     if (isset($match['style']) && !empty($match['style'])) {
         $this->value['style'] = $styleParser->parse($match['style'])->value;
     }
     if (isset($match['color']) && !empty($match['color'])) {
         $this->value['color'] = $colorParser->parse($match['color'])->value;
     }
     return $this;
 }
Esempio n. 3
0
 public function testRenderLayeredPolygons()
 {
     $driver = $this->getDriver();
     $driver->createPage(210, 297);
     $color = new ezcDocumentPcssStyleColorValue();
     $color->parse('#204a87');
     $driver->drawPolygon(array(array(10, 10), array(200, 10), array(105, 287)), $color->value);
     $color = new ezcDocumentPcssStyleColorValue();
     $color->parse('#2e3436');
     $driver->drawPolyline(array(array(200, 287), array(105, 10), array(10, 287)), $color->value, 1, false);
     $pdf = $driver->save();
     $this->assertPdfDocumentsSimilar($pdf, get_class($driver) . '_' . __FUNCTION__);
 }