Add test case for this bug
- Fix whitespaces in MarkdownTest
This commit is contained in:
parent
4a85de4c19
commit
515935b241
4 changed files with 111 additions and 52 deletions
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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue