feat: add MCP server for the website chatbot over a mirrored TYPO3 content feed
This commit is contained in:
1 parent
ff7ddf7a9e
commit
1b4384e3f3
52 files changed
+5117
-4
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\ContentFeed;
|
||||
|
||||
use App\ContentFeed\HtmlToMarkdownConverter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HtmlToMarkdownConverterTest extends TestCase
|
||||
{
|
||||
private HtmlToMarkdownConverter $converter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->converter = new HtmlToMarkdownConverter();
|
||||
}
|
||||
|
||||
public function testDropsEmbedsMediaAndFormsWithTheirContent(): void
|
||||
{
|
||||
$markdown = $this->converter->convert('<p>Text</p><script>alert(1)</script><style>p{}</style><noscript>No JS</noscript><iframe src="https://youtube.com"></iframe><img src="a.jpg" alt="Bild"><picture><source></picture><svg><text>Icon</text></svg><form><label>Name</label></form>');
|
||||
|
||||
self::assertSame('Text', $markdown);
|
||||
}
|
||||
|
||||
public function testKeepsHeadingsListsTablesAndEmphasis(): void
|
||||
{
|
||||
$markdown = $this->converter->convert('<h2>Leistungen</h2><ul><li><strong>Skipass</strong></li><li><em>Bus</em></li></ul><table><tr><th>A</th><th>B</th></tr><tr><td>1</td><td>2</td></tr></table>');
|
||||
|
||||
self::assertSame("## Leistungen\n\n- **Skipass**\n- *Bus*\n\n| A | B |\n|---|---|\n| 1 | 2 |", $markdown);
|
||||
}
|
||||
|
||||
public function testResolvesRelativeLinksAgainstTheDocumentUrl(): void
|
||||
{
|
||||
$markdown = $this->converter->convert('<a href="/agb">AGB</a> <a href="kontakt">Kontakt</a> <a href="mailto:[email protected]">Mail</a> <a href="https://snowzone.net/">SZ</a>', 'https://www.ep-reisen.de/info/reise');
|
||||
|
||||
self::assertSame('[AGB](https://www.ep-reisen.de/agb) [Kontakt](https://www.ep-reisen.de/info/kontakt) [Mail](mailto:[email protected]) [SZ](https://snowzone.net/)', $markdown);
|
||||
}
|
||||
|
||||
public function testCollapsesTemplateWhitespaceAndDecodesEntities(): void
|
||||
{
|
||||
$markdown = $this->converter->convert("<div>\n <a href=\"/x\">\n Ski-\n Gruppenhäuser\n </a></div>\n\n\n\n<p>Essen & Trinken</p>", 'https://www.ep-reisen.de/');
|
||||
|
||||
self::assertSame("[Ski- Gruppenhäuser](https://www.ep-reisen.de/x)\n\nEssen & Trinken", $markdown);
|
||||
}
|
||||
|
||||
public function testEmptyInputIsEmpty(): void
|
||||
{
|
||||
self::assertSame('', $this->converter->convert(null));
|
||||
self::assertSame('', $this->converter->convert(' '));
|
||||
self::assertSame('', $this->converter->convert('<article><img src="a.jpg"></article>'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user