コード例 #1
0
 public function testOnOutputPageParserOutput()
 {
     $altLinks = array(array('a' => 'b'), array('c', 'd'));
     $context = new DerivativeContext(RequestContext::getMain());
     $out = new OutputPage($context);
     $parserOutput = $this->getMock('ParserOutput');
     $parserOutput->expects($this->exactly(3))->method('getExtensionData')->will($this->returnCallback(function ($key) use($altLinks) {
         if ($key === 'wikibase-alternate-links') {
             return $altLinks;
         } else {
             return $key;
         }
     }));
     RepoHooks::onOutputPageParserOutput($out, $parserOutput);
     $this->assertSame('wikibase-view-chunks', $out->getProperty('wikibase-view-chunks'));
     $this->assertSame('wikibase-titletext', $out->getProperty('wikibase-titletext'));
     $this->assertSame($altLinks, $out->getLinkTags());
 }
コード例 #2
0
 /**
  * Tests the FormatAutocomment hook provided by RepoHooks.
  *
  * @todo move to RepoHooksTest
  *
  * @dataProvider providerOnFormat
  */
 public function testOnFormat($model, $root, $pre, $auto, $post, $title, $local, $expected)
 {
     $itemTitle = $this->getMock($title);
     $itemTitle->expects($this->once())->method('getContentModel')->will($this->returnValue($model));
     $comment = null;
     RepoHooks::onFormat(array($model, $root), $comment, $pre, $auto, $post, $itemTitle, $local);
     if (is_null($expected)) {
         $this->assertEquals($expected, $comment, "Didn't find the expected null");
     } else {
         $this->assertRegExp($expected, $comment, "Didn't find the expected final comment");
     }
 }