Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulien Veyssier <eneiluj@posteo.net>2022-05-24 15:59:57 +0300
committerJulien Veyssier <eneiluj@posteo.net>2022-05-24 15:59:57 +0300
commitc44751edc28faf397f3209b24d11647559fb3017 (patch)
tree44642f0994301427de4e1e56eb15c8fa5f9f6550 /tests
parentedfd0d20e27c7af7a000fc882ecf409df0a54524 (diff)
manual backport of #2426, refs #2411, Improve image attachment management
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/Service/ImageServiceTest.php (renamed from tests/TextTest.php)54
1 files changed, 36 insertions, 18 deletions
diff --git a/tests/TextTest.php b/tests/unit/Service/ImageServiceTest.php
index bfa4251fb..ffbba391d 100644
--- a/tests/TextTest.php
+++ b/tests/unit/Service/ImageServiceTest.php
@@ -6,28 +6,29 @@ use OCA\Text\AppInfo\Application;
use OCA\Text\Service\ImageService;
use OCP\Files\Folder;
-class TextTest extends \PHPUnit\Framework\TestCase {
+class ImageServiceTest 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);
}
}