コード例 #1
0
ファイル: ParserTest.php プロジェクト: gitiki/gitiki
 /**
  * @see https://github.com/erusev/parsedown/issues/358
  * @see https://github.com/gitiki/Gitiki/issues/7
  */
 public function testPageWithoutDuplicatedLink()
 {
     $page = new Page('test');
     $page->setContent('[http://gitiki.org](http://gitiki.org/)');
     (new Parser())->page($page);
     $this->assertSame('<p><a href="http://gitiki.org/">http://gitiki.org</a></p>', $page->getContent());
 }
コード例 #2
0
ファイル: MarkdownTest.php プロジェクト: gitiki/gitiki
 public function testOnContent()
 {
     $page = new Page('test');
     $page->setContent('# Hello World!');
     (new Markdown())->onContent(new GenericEvent($page));
     $this->assertSame('<h1 id="hello-world">Hello World!</h1>', $page->getContent());
 }
コード例 #3
0
ファイル: MetadataTest.php プロジェクト: gitiki/gitiki
 /**
  * @dataProvider provideContent
  */
 public function testOnMetaLoad($content, $expectedMetas, $expectedContent, $comment)
 {
     $page = new Page('test');
     $page->setContent($content);
     (new Metadata())->onMetaLoad(new GenericEvent($page));
     $this->assertSame($expectedMetas, $page->getMetas(), $comment);
     $this->assertSame($expectedContent, $page->getContent(), $comment);
 }
コード例 #4
0
ファイル: ImageTest.php プロジェクト: gitiki/gitiki
 /**
  * @dataProvider provideContent
  */
 public function testOnMeta($content, $expected, $comment)
 {
     $page = new Page('test');
     $page->setContent($content);
     $routes = new RouteCollection();
     $routes->add('image', new Route('/{path}.{_format}', [], ['path' => '[\\w\\d/]+', '_format' => '(jpe?g|png|gif)']));
     $requestContext = new RequestContext('/foo.php');
     (new Image(new UrlGenerator(new PathResolver($requestContext), new RealUrlGenerator($routes, $requestContext))))->onContent(new GenericEvent($page));
     $this->assertSame($expected, $page->getContent(), $comment);
 }
コード例 #5
0
ファイル: WikiLinkTest.php プロジェクト: stof/Gitiki
 /**
  * @dataProvider provideContent
  */
 public function testOnMeta($content, $expected, $comment)
 {
     $page = new Page('test');
     $page->setContent($content);
     $routes = new RouteCollection();
     $routes->add('page', new Route('/{path}.{_format}', [], ['path' => '[\\w\\d-/]+', '_format' => 'html']));
     $routes->add('page_dir', new Route('/{path}', [], ['path' => '([\\w\\d-/]+/|)$']));
     $requestContext = new RequestContext('/foo.php');
     $pathResolver = new PathResolver($requestContext);
     (new WikiLink(__DIR__ . '/fixtures', $pathResolver, new UrlGenerator($pathResolver, new RealUrlGenerator($routes, $requestContext))))->onContent(new GenericEvent($page));
     $this->assertSame($expected, $page->getContent(), $comment);
 }
コード例 #6
0
ファイル: ParserTest.php プロジェクト: stof/Gitiki
    public function testPage()
    {
        $parser = new Parser();
        $page = new Page('test');
        $page->setContent(<<<EOF
# Hello World!

## foo bar
EOF
);
        $parser->page($page);
        $this->assertSame([['id' => 'hello-world', 'text' => 'Hello World!', 'children' => [['id' => 'foo-bar', 'text' => 'foo bar']]]], $page->getToc());
    }