Add test case for this bug
- Fix whitespaces in MarkdownTest
This commit is contained in:
parent
4a85de4c19
commit
515935b241
1
tests/datasets/content/text/html/bug-7457.html
Normal file
1
tests/datasets/content/text/html/bug-7457.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<h2 data-sourcepos="1:1-1:23" dir="auto">
<a id="user-content-104-2019-08-01" class="anchor" href="#104-2019-08-01" aria-hidden="true"></a>[1.0.4] - 2019-08-01</h2>
<h3 data-sourcepos="2:1-2:9" dir="auto">
<a id="user-content-fixed" class="anchor" href="#fixed" aria-hidden="true"></a>Fixed</h3>
<ul data-sourcepos="3:1-3:116" dir="auto">
<li data-sourcepos="3:1-3:116">Invalid SemVer version generation, when the current branch does not have commits ahead of tag/checked out on a tag</li>
</ul>
|
5
tests/datasets/content/text/html/bug-7457.txt
Normal file
5
tests/datasets/content/text/html/bug-7457.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
*[1.0.4] - 2019-08-01*
|
||||||
|
|
||||||
|
*Fixed*
|
||||||
|
|
||||||
|
* Invalid SemVer version generation, when the current branch does not have commits ahead of tag/checked out on a tag
|
53
tests/src/Content/Text/HTMLTest.php
Normal file
53
tests/src/Content/Text/HTMLTest.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Test\src\Content\Text;
|
||||||
|
|
||||||
|
use Friendica\Content\Text\HTML;
|
||||||
|
use Friendica\Test\MockedTest;
|
||||||
|
use Friendica\Test\Util\AppMockTrait;
|
||||||
|
use Friendica\Test\Util\VFSTrait;
|
||||||
|
|
||||||
|
class HTMLTest extends MockedTest
|
||||||
|
{
|
||||||
|
use VFSTrait;
|
||||||
|
use AppMockTrait;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->setUpVfsDir();
|
||||||
|
$this->mockApp($this->root);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataHTML()
|
||||||
|
{
|
||||||
|
$inputFiles = glob(__DIR__ . '/../../../datasets/content/text/html/*.html');
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($inputFiles as $file) {
|
||||||
|
$data[str_replace('.html', '', $file)] = [
|
||||||
|
'input' => file_get_contents($file),
|
||||||
|
'expected' => file_get_contents(str_replace('.html', '.txt', $file))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test convert different input Markdown text into HTML
|
||||||
|
*
|
||||||
|
* @dataProvider dataHTML
|
||||||
|
*
|
||||||
|
* @param string $input The Markdown text to test
|
||||||
|
* @param string $expected The expected HTML output
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function testToPlaintext($input, $expected)
|
||||||
|
{
|
||||||
|
$output = HTML::toPlaintext($input, 0);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $output);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,52 +1,52 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Friendica\Test\src\Content\Text;
|
namespace Friendica\Test\src\Content\Text;
|
||||||
|
|
||||||
use Friendica\Content\Text\Markdown;
|
use Friendica\Content\Text\Markdown;
|
||||||
use Friendica\Test\MockedTest;
|
use Friendica\Test\MockedTest;
|
||||||
use Friendica\Test\Util\AppMockTrait;
|
use Friendica\Test\Util\AppMockTrait;
|
||||||
use Friendica\Test\Util\VFSTrait;
|
use Friendica\Test\Util\VFSTrait;
|
||||||
|
|
||||||
class MarkdownTest extends MockedTest
|
class MarkdownTest extends MockedTest
|
||||||
{
|
{
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
use AppMockTrait;
|
use AppMockTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
$this->mockApp($this->root);
|
$this->mockApp($this->root);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataMarkdown()
|
public function dataMarkdown()
|
||||||
{
|
{
|
||||||
$inputFiles = glob(__DIR__ . '/../../../datasets/content/text/markdown/*.md');
|
$inputFiles = glob(__DIR__ . '/../../../datasets/content/text/markdown/*.md');
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
foreach ($inputFiles as $file) {
|
foreach ($inputFiles as $file) {
|
||||||
$data[str_replace('.md', '', $file)] = [
|
$data[str_replace('.md', '', $file)] = [
|
||||||
'input' => file_get_contents($file),
|
'input' => file_get_contents($file),
|
||||||
'expected' => file_get_contents(str_replace('.md', '.html', $file))
|
'expected' => file_get_contents(str_replace('.md', '.html', $file))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test convert different input Markdown text into HTML
|
* Test convert different input Markdown text into HTML
|
||||||
* @dataProvider dataMarkdown
|
* @dataProvider dataMarkdown
|
||||||
*
|
*
|
||||||
* @param string $input The Markdown text to test
|
* @param string $input The Markdown text to test
|
||||||
* @param string $expected The expected HTML output
|
* @param string $expected The expected HTML output
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function testConvert($input, $expected)
|
public function testConvert($input, $expected)
|
||||||
{
|
{
|
||||||
$output = Markdown::convert($input);
|
$output = Markdown::convert($input);
|
||||||
|
|
||||||
$this->assertEquals($expected, $output);
|
$this->assertEquals($expected, $output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue