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 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); }
/** * @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 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']); }