ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilWebDAVCheckValidTitleTraitTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
24{
25 use ilWebDAVCheckValidTitleTrait;
26
30 protected array $notDavableCharacters = [
31 '\\',
32 '<',
33 '>',
34 '/',
35 ':',
36 '*',
37 '?',
38 '"',
39 '|',
40 '#'
41 ];
42
46 protected array $randomUnicodeStrings = [
47 '斛翔簫輷㠋캍쵮읞㉡⚫ﴏ',
48 'ੳ卵Ὃ죿퐥㿼㘩輔푬㳟宵錠◷⻨돁',
49 '㿃㺝ᅴ㙂楳⦍텥鹰⍛合븺쑂瀎屴',
50 '42342afafasfERf',
51 'ADFsdf234df',
52 'afas 234ADFASFD',
53 '_23daf32DE簫'
54 ];
55
56 public function testDAVableTitleWithStringsOfValidCharactersReturnsTrue(): void
57 {
58 foreach ($this->randomUnicodeStrings as $filename) {
59 $this->assertTrue(
60 $this->isDAVableObjTitle($filename)
61 );
62 }
63 }
64
65 public function testDAVableTitleWithForbiddenCharactersReturnsFalse(): void
66 {
67 foreach (str_split('\\<>/:*?"|#') as $forbidden_character) {
68 $this->assertFalse(
69 $this->isDAVableObjTitle(
70 $this->randomUnicodeStrings[array_rand($this->randomUnicodeStrings)]
71 . $forbidden_character
72 . $this->randomUnicodeStrings[array_rand($this->randomUnicodeStrings)]
73 )
74 );
75 }
76 }
77
78 public function testDAVableTitleWithHiddenFileReturnsFalse(): void
79 {
80 foreach ($this->randomUnicodeStrings as $filename) {
81 $this->assertFalse(
82 $this->isDAVableObjTitle('.' . $filename)
83 );
84 }
85 }
86}
$filename
Definition: buildRTE.php:78