blob: aeaa8d0cc1207848d28ba1c3a00bf11a23e3ddce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?php
namespace OCA\Text\Tests;
use OCA\Text\AppInfo\Application;
use OCA\Text\Service\ImageService;
class TextTest extends \PHPUnit\Framework\TestCase {
public function testDummy() {
$app = new Application();
$this->assertEquals('text', $app::APP_NAME);
}
public function testGetAttachmentNamesFromContent() {
$contentNames = [
'aaa.png',
'a[a]a.png',
'a(a)a.png',
'a](a.png',
',;:!?.§-_a_',
'a`a`.png',
];
$content = "some content\n";
foreach ($contentNames as $name) {
// this is how it's generated in MenuBar.vue
$linkText = preg_replace('/[[\]]/', '', $name);
$encodedName = urlencode($name);
$content .= '![' . $linkText . '](text://image?imageFileName=' . $encodedName . ")\n";
}
$content .= 'some content';
$computedNames = ImageService::getAttachmentNamesFromContent($content);
foreach ($contentNames as $contentName) {
$this->assertContains($contentName, $computedNames);
}
}
}
|