Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ services:
alias: text_formatter.s9e.renderer

phpbb\textformatter\cache_interface:
alias: text_formatter.cache
alias: text_formatter.s9e.factory

phpbb\textformatter\parser_interface:
alias: text_formatter.parser
alias: text_formatter.s9e.parser

phpbb\textformatter\renderer_interface:
alias: text_formatter.renderer
alias: text_formatter.s9e.renderer

phpbb.pages.admin.controller:
class: phpbb\pages\controller\admin_controller
Expand Down
36 changes: 0 additions & 36 deletions tests/functional/version_check_test.php

This file was deleted.

19 changes: 14 additions & 5 deletions tests/functional/viewonline_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,27 @@ public function test_viewonline_check($page_title)

// Check each entry in the viewonline table
// Skip the first row (header)
$admin_found = false;
$expected_location = $this->lang('PAGES_VIEWONLINE', $page_title);
$matching_session_found = false;
for ($i = 1; $i < $session_entries; $i++)
{
// If we found the admin, we check his page info and leave
// Multiple admin sessions can exist from earlier functional tests.
// Look for the session visiting this test page rather than relying
// on database row order.
$subcrawler = $crawler->filter('#page-body table.table1 tr')->eq($i);
if (strpos($subcrawler->filter('td')->text(), 'admin') !== false)
{
self::assertStringContainsString($this->lang('PAGES_VIEWONLINE', $page_title), $subcrawler->filter('td.info')->text());
return;
$admin_found = true;
if (strpos($subcrawler->filter('td.info')->text(), $expected_location) !== false)
{
$matching_session_found = true;
break;
}
}
}

// If we did not find the admin, we fail
self::fail('User "admin" was not found on viewonline page.');
self::assertTrue($admin_found, 'User "admin" was not found on viewonline page.');
self::assertTrue($matching_session_found, 'The admin session for the Viewonline test page was not found.');
}
}
96 changes: 95 additions & 1 deletion tests/textformatter/factory_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function get_styles_templates()

class factory_test extends \phpbb_test_case
{
public function test_configurator_enables_litedown()
public function test_configurator_enables_markdown_plugins()
{
global $config, $phpbb_root_path, $request, $symfony_request, $user;

Expand Down Expand Up @@ -83,5 +83,99 @@ public function test_configurator_enables_litedown()
$configurator = $factory->get_configurator();

self::assertTrue(isset($configurator->Litedown));
self::assertTrue(isset($configurator->PipeTables));
}

public function test_markdown_headers_have_litedown_ids()
{
global $config, $phpbb_root_path, $request, $symfony_request, $user;

$config = new \phpbb\config\config(array(
'allowed_schemes_links' => 'http,https',
'cookie_secure' => false,
'force_server_vars' => true,
'script_path' => '/phpbb',
'server_name' => 'localhost',
'server_port' => 80,
'server_protocol' => 'http://',
));
$request = new \phpbb_mock_request();
$symfony_request = new \phpbb\symfony_request($request);
$user = new \phpbb_mock_user();

$data_access = new factory_data_access(
file_get_contents($phpbb_root_path . 'styles/prosilver/template/bbcode.html')
);
$factory = new \phpbb\pages\textformatter\factory(
$data_access,
new \phpbb_mock_cache(),
new \phpbb_mock_event_dispatcher(),
$config,
new \phpbb\textformatter\s9e\link_helper(),
new \phpbb\log\dummy(),
sys_get_temp_dir() . '/',
'_pages_test_parser',
'_pages_test_renderer'
);

$objects = $factory->get_configurator()->finalize();
$xml = $objects['parser']->parse(
"# Basic usage\n\n"
. "## Global options (work on every command)\n\n"
. "## cache — cache management\n\n"
. "## Quick-reference table"
);
$html = $objects['renderer']->render($xml);

self::assertStringContainsString('<h1 id="basic-usage">Basic usage</h1>', $html);
self::assertStringContainsString('<h2 id="global-options-work-on-every-command">Global options (work on every command)</h2>', $html);
self::assertStringContainsString('<h2 id="cache-cache-management">cache — cache management</h2>', $html);
self::assertStringContainsString('<h2 id="quick-reference-table">Quick-reference table</h2>', $html);
}

public function test_markdown_pipe_tables_are_rendered()
{
global $config, $phpbb_root_path, $request, $symfony_request, $user;

$config = new \phpbb\config\config(array(
'allowed_schemes_links' => 'http,https',
'cookie_secure' => false,
'force_server_vars' => true,
'script_path' => '/phpbb',
'server_name' => 'localhost',
'server_port' => 80,
'server_protocol' => 'http://',
));
$request = new \phpbb_mock_request();
$symfony_request = new \phpbb\symfony_request($request);
$user = new \phpbb_mock_user();

$data_access = new factory_data_access(
file_get_contents($phpbb_root_path . 'styles/prosilver/template/bbcode.html')
);
$factory = new \phpbb\pages\textformatter\factory(
$data_access,
new \phpbb_mock_cache(),
new \phpbb_mock_event_dispatcher(),
$config,
new \phpbb\textformatter\s9e\link_helper(),
new \phpbb\log\dummy(),
sys_get_temp_dir() . '/',
'_pages_table_test_parser',
'_pages_table_test_renderer'
);

$objects = $factory->get_configurator()->finalize();
$xml = $objects['parser']->parse(
"| Option | Meaning |\n"
. "|---|---|\n"
. "| `--safe-mode` | Boot without extensions |"
);
$html = $objects['renderer']->render($xml);

self::assertStringContainsString('<table>', $html);
self::assertStringContainsString('<th>Option</th>', $html);
self::assertStringContainsString('<td><code>--safe-mode</code></td>', $html);
self::assertStringContainsString('<td>Boot without extensions</td>', $html);
}
}
7 changes: 7 additions & 0 deletions textformatter/factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public function get_configurator()
$configurator->Litedown;
}

$configurator->Litedown->addHeadersId();

if (!isset($configurator->PipeTables))
{
$configurator->PipeTables;
}

return $configurator;
}
}