/**
  * @testdox filterAttributes() calls the logger's setAttribute() and unsetAttribute() methods for each attribute with a filterChain
  */
 public function testFilterAttributesCallsLoggerSetAttribute()
 {
     $logger = $this->getMock('s9e\\TextFormatter\\Parser\\Logger', ['setAttribute', 'unsetAttribute']);
     $logger->expects($this->at(0))->method('setAttribute')->with('foo');
     $logger->expects($this->at(2))->method('setAttribute')->with('bar');
     $logger->expects($this->exactly(2))->method('unsetAttribute');
     $tagConfig = new TagConfig();
     $tagConfig->attributes->add('foo')->filterChain->append(function () {
     });
     $tagConfig->attributes->add('bar')->filterChain->append(function () {
     });
     $tag = new Tag(Tag::SELF_CLOSING_TAG, 'X', 0, 0);
     $tag->setAttribute('foo', 'foo');
     $tag->setAttribute('bar', 'bar');
     Parser::filterAttributes($tag, $tagConfig->asConfig(), [], $logger);
 }
Exemplo n.º 2
0
 /**
  * Rebuild a tag's template
  *
  * @param  Tag    $tag         Source tag
  * @param  string $elName      Name of the HTML element created by the template
  * @param  bool   $allowUnsafe Whether to allow unsafe markup
  * @return void
  */
 protected function rebuildTemplate(Tag $tag, $elName, $allowUnsafe)
 {
     $template = '<' . $elName . '>';
     foreach ($tag->attributes as $attrName => $attribute) {
         $template .= '<xsl:copy-of select="@' . $attrName . '"/>';
     }
     $template .= '<xsl:apply-templates/></' . $elName . '>';
     if ($allowUnsafe) {
         $template = new UnsafeTemplate($template);
     }
     $tag->setTemplate($template);
 }
Exemplo n.º 3
0
 /**
  * @testdox asConfig() does not modify the tag's filterChain itself
  */
 public function testFilterChainConfigIsSafe()
 {
     $tag = new Tag();
     $config = $tag->asConfig();
     $tag->attributes->add('foo');
     $config = $tag->asConfig();
     $this->assertArrayHasKey('filterChain', $config);
 }