ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilUtilsPreventTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
23class ilUtilsPreventTest extends TestCase
24{
25 private function extractMethodNames(array $reflection_methods): array
26 {
27 return array_map(function (ReflectionMethod $m): string {
28 return $m->getName();
29 }, $reflection_methods);
30 }
31
32 public function testAmountOfMethodsInUtil(): void
33 {
34 $r = new ReflectionClass(ilUtil::class);
35 $methods = $this->extractMethodNames($r->getMethods());
36 $amount_of_methods = count($methods);
37 $this->assertEquals(48, $amount_of_methods);
38 $this->assertEquals([
39 0 => 'getImageTagByType',
40 1 => 'getImagePath',
41 2 => 'getHtmlPath',
42 3 => 'getStyleSheetLocation',
43 4 => 'getNewContentStyleSheetLocation',
44 5 => 'switchColor',
45 6 => 'makeClickable',
46 7 => 'replaceLinkProperties',
47 8 => 'is_email',
48 9 => 'isLogin',
49 10 => 'img',
50 11 => 'deliverData',
51 12 => 'appendUrlParameterString',
52 13 => 'stripSlashes',
53 14 => 'stripOnlySlashes',
54 15 => 'secureString',
55 16 => 'getSecureTags',
56 17 => 'maskSecureTags',
57 18 => 'unmaskSecureTags',
58 19 => 'securePlainString',
59 20 => 'htmlencodePlainString',
60 21 => 'maskAttributeTag',
61 22 => 'unmaskAttributeTag',
62 23 => 'maskTag',
63 24 => 'unmaskTag',
64 25 => 'secureLink',
65 26 => 'stripScriptHTML',
66 27 => 'secureUrl',
67 28 => 'extractParameterString',
68 29 => 'yn2tf',
69 30 => 'tf2yn',
70 31 => 'deducibleSize',
71 32 => 'redirect',
72 33 => 'insertInstIntoID',
73 34 => 'groupNameExists',
74 35 => 'isWindows',
75 36 => 'now',
76 37 => '_getObjectsByOperations',
77 38 => 'isHTML',
78 39 => '__extractRefId',
79 40 => '__extractId',
80 41 => '_sortIds',
81 42 => 'getSystemMessageHTML',
82 43 => 'setCookie',
83 44 => '_getHttpPath',
84 45 => 'parseImportId',
85 46 => 'fmtFloat',
86 47 => 'formatSize',
87 ], $methods);
88 }
89
90 public function testAmountOfMethodsInArrayUtil(): void
91 {
92 $r = new ReflectionClass(ilArrayUtil::class);
93 $methods = $this->extractMethodNames($r->getMethods());
94 $amount_of_methods = count($methods);
95 $this->assertEquals(8, $amount_of_methods);
96 $this->assertEquals([
97 0 => 'quoteArray',
98 1 => 'stripSlashesRecursive',
99 2 => 'stripSlashesArray',
100 3 => 'sortArray',
101 4 => 'sort_func',
102 5 => 'sort_func_numeric',
103 6 => 'mergesort',
104 7 => 'stableSortArray',
105 ], $methods);
106 }
107
108 public function testAmountOfMethodsInShellUtil(): void
109 {
110 $r = new ReflectionClass(ilShellUtil::class);
111 $methods = $this->extractMethodNames($r->getMethods());
112 $amount_of_methods = count($methods);
113 $this->assertEquals(9, $amount_of_methods);
114 $this->assertEquals([
115 0 => 'resizeImage',
116 1 => 'escapeShellArg',
117 2 => 'processConvertVersion',
118 3 => 'escapeShellCmd',
119 4 => 'execQuoted',
120 5 => 'isConvertVersionAtLeast',
121 6 => 'getConvertCmd',
122 7 => 'convertImage',
123 8 => 'execConvert',
124 ], $methods);
125 }
126
128 {
129 $r = new ReflectionClass(ilLegacyFormElementsUtil::class);
130 $methods = $this->extractMethodNames($r->getMethods());
131 $amount_of_methods = count($methods);
132 $this->assertEquals(7, $amount_of_methods);
133 $this->assertEquals([
134 0 => 'prepareFormOutput',
135 1 => 'period2String',
136 2 => 'prepareTextareaOutput',
137 3 => 'makeTimeSelect',
138 4 => 'formCheckbox',
139 5 => 'formSelect',
140 6 => 'formRadioButton',
141 ], $methods);
142 }
143
144 public function testAmountOfMethodsInStrUtil(): void
145 {
146 $r = new ReflectionClass(ilStr::class);
147 $methods = $this->extractMethodNames($r->getMethods());
148 $amount_of_methods = count($methods);
149 $this->assertEquals(12, $amount_of_methods);
150 $this->assertEquals([
151 0 => 'subStr',
152 1 => 'strPos',
153 2 => 'strIPos',
154 3 => 'strLen',
155 4 => 'strToLower',
156 5 => 'strToUpper',
157 6 => 'strCmp',
158 7 => 'shortenText',
159 8 => 'isUtf8',
160 9 => 'convertUpperCamelCaseToUnderscoreCase',
161 10 => 'shortenTextExtended',
162 11 => 'shortenWords',
163 ], $methods);
164 }
165}
extractMethodNames(array $reflection_methods)