public function setUp()
 {
     $parser = new HaikMarkdown();
     $basic_repository = new BasicPluginRepository($parser);
     $bootstrap_repository = new BootstrapPluginRepository($parser);
     $parser->registerPluginRepository($basic_repository)->registerPluginRepository($bootstrap_repository);
     $this->parser = $parser;
 }
Exemplo n.º 2
0
    public function testConvertReferenceIdToLowerCase()
    {
        $plugin_mock = Mockery::mock('Hokuken\\HaikMarkdown\\Plugin\\PluginInterface', function ($mock) {
            $mock->shouldReceive('convert')->with(array('foo'), 'text' . "\n")->andReturn('<div>convert plugin</div>');
            $mock->shouldReceive('inline')->with(array('foo'), 'body' . "\n")->andReturn('<span>inline plugin</span>');
            return $mock;
        });
        $plugin_repository = Mockery::mock('Hokuken\\HaikMarkdown\\Plugin\\Repositories\\PluginRepositoryInterface', function ($mock) use($plugin_mock) {
            $mock->shouldReceive('exists')->andReturn(true);
            $mock->shouldReceive('load')->andReturn($plugin_mock);
            return $mock;
        });
        $parser = new HaikMarkdown();
        $parser->registerPluginRepository($plugin_repository);
        $markdown = <<<EOM
::: [ref-id]
text
:::

This is a /[body][ref-id].

[REF-ID]: plugin foo

EOM;
        $result = $parser->transform($markdown);
        $expected = ['tag' => 'div', 'content' => 'convert plugin'];
        $this->assertTag($expected, $result);
    }