/** * @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()); }
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()); }
/** * @dataProvider provideMetas */ public function testOnMetaParse($metas, $comment) { $page = new Page('test'); $page->setMetas($metas); (new Metadata())->onMetaParse(new GenericEvent($page)); $this->assertInternalType('array', $page->getMetas(), $comment); $this->assertEquals(['foo' => 'bar'], $page->getMetas(), $comment); }
/** * @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); }
/** * @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); }
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()); }
public function testOnMeta() { $this->markTestSkipped(); $page = new Page('test'); $page->setMetas(['title' => 'Hello World!']); $event = new GenericEvent($page); $redirect = new Redirect(new PathResolver(new RequestContext('/foo.php'))); // no redirect $redirect->onMeta(new GenericEvent($page)); // set meta redirect $page->setMetas(['redirect' => 'foobar']); $this->setExpectedException('Gitiki\\Exception\\PageRedirectedException'); $redirect->onMeta($event); }
public function testOnLoad() { $page = new Page('/bar.md'); (new FileLoader(__DIR__ . '/fixtures'))->onLoad(new GenericEvent($page)); $this->assertSame(file_get_contents(__DIR__ . '/fixtures/bar.md'), $page->getContent()); }
public function sourceAction(Gitiki $gitiki, Request $request, $path) { $page = new Page($path); $gitiki['dispatcher']->dispatch(Events::PAGE_LOAD, new GenericEvent($page)); return new Response($page->getContent(), 200, ['content-type' => 'text/plain']); }