diff options
author | Julien Veyssier <eneiluj@posteo.net> | 2022-05-20 14:00:02 +0300 |
---|---|---|
committer | Julien Veyssier <eneiluj@posteo.net> | 2022-05-23 17:32:03 +0300 |
commit | cad9a1d7f62fb5d3e2ba5eb053497ad207f5aee4 (patch) | |
tree | bc51c6458a7df127a73754d28471b6a51a3159ad /tests | |
parent | 401bdb3566dc6b483b89e57bed51ebfe6624756c (diff) |
change image target in markdown content to relative path, handle it in ImageView
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/TextTest.php | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/tests/TextTest.php b/tests/TextTest.php index bfa4251fb..149fedda8 100644 --- a/tests/TextTest.php +++ b/tests/TextTest.php @@ -7,27 +7,28 @@ use OCA\Text\Service\ImageService; use OCP\Files\Folder; class TextTest extends \PHPUnit\Framework\TestCase { + private static $attachmentNames = [ + 'aaa.png', + 'aaa (2).png', + 'aaa 2).png', + 'aaa (2.png', + 'aaa ((2.png', + 'aaa 2)).png', + 'a[a]a.png', + 'a(a)a.png', + 'a](a.png', + ',;:!?.§-_a_', + 'a`a`.png', + ]; + public function testDummy() { $app = new Application(); $this->assertEquals('text', $app::APP_NAME); } - public function testGetAttachmentNamesFromContent() { - $contentNames = [ - 'aaa.png', - 'aaa (2).png', - 'aaa 2).png', - 'aaa (2.png', - 'aaa ((2.png', - 'aaa 2)).png', - 'a[a]a.png', - 'a(a)a.png', - 'a](a.png', - ',;:!?.§-_a_', - 'a`a`.png', - ]; + public function testGetOldAttachmentNamesFromContent() { $content = "some content\n"; - foreach ($contentNames as $name) { + foreach (self::$attachmentNames as $name) { // this is how it's generated in MenuBar.vue $linkText = preg_replace('/[[\]]/', '', $name); $encodedName = urlencode($name); @@ -35,8 +36,25 @@ class TextTest extends \PHPUnit\Framework\TestCase { } $content .= 'some content'; - $computedNames = ImageService::getAttachmentNamesFromContent($content); - foreach ($contentNames as $contentName) { + $computedNames = ImageService::getAttachmentNamesFromContent($content, 33); + foreach (self::$attachmentNames as $contentName) { + $this->assertContains($contentName, $computedNames); + } + } + + + public function testGetAttachmentNamesFromContent() { + $content = "some content\n"; + foreach (self::$attachmentNames as $name) { + // this is how it's generated in MenuBar.vue + $linkText = preg_replace('/[[\]]/', '', $name); + $encodedName = urlencode($name); + $content .= '![' . $linkText . '](.attachments.33/' . $encodedName . ")\n"; + } + $content .= 'some content'; + + $computedNames = ImageService::getAttachmentNamesFromContent($content, 33); + foreach (self::$attachmentNames as $contentName) { $this->assertContains($contentName, $computedNames); } } |