예제 #1
0
 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());
 }
예제 #2
0
 /**
  * @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);
 }
예제 #3
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);
 }
예제 #4
0
 /**
  * @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);
 }
예제 #5
0
 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());
 }
예제 #6
0
 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']);
 }