3 require_once(
"libs/composer/vendor/autoload.php");
49 array(
'purpose',
'composition',
'effect',
'rival');
52 array(
'usage',
'interaction',
'wording',
'style',
'ordering',
'responsiveness',
53 'composition',
'accessibility');
60 $reflection =
new ReflectionClass($docstring_data[
"namespace"]);
61 return in_array(
"ILIAS\\UI\\Component\\Component", $reflection->getInterfaceNames());
65 return preg_match(
"#^(\\\\)?ILIAS\\\\UI\\\\Component\\\\([a-zA-Z]+\\\\)*Factory$#", $name) === 1;
69 return new ReflectionClass($this->factory_title);
74 return array_map(
function($element) {
75 return array($element, $element->getName());
76 }, $reflection->getMethods());
87 $message =
"TODO: Put your factory into the proper namespace.";
89 (
"#^ILIAS\\\\UI\\\\Component.#" 90 , $this->reflection->getNamespaceName()
96 $name = $this->reflection->getName();
97 $message =
"TODO: Give your factory a proper name.";
112 $function_name_string =
"\n public function ".$method_reflection->getName().
"()";
113 $docstring_data = $this->yaml_parser->parseArrayFromString(
114 $method_reflection->getDocComment().$function_name_string);
115 $this->assertTrue(
true);
118 $message =
"TODO ($name): fix parse error in kitchen sink yaml: ".$e->getMessage();
119 $this->assertTrue(
false, $message);
121 $this->assertCount(1, $docstring_data);
122 return $docstring_data[0];
131 $message =
"TODO ($name): fix return type, it must be a factory or a component.";
134 $this->assertTrue(
true);
137 $this->assertTrue(
true);
140 $this->assertTrue(
false, $message);
153 $return_doc = $docstring_data[
"namespace"];
154 $name_uppercase = ucwords($name);
156 $regex_head =
"#^(\\\\?)$regex_factory_namespace";
158 $message =
"TODO ($name): fix @return, it does not match the method name.";
161 (
"$regex_head\\\\$name_uppercase\\\\Factory$#" 169 $standard_pattern =
"$regex_head\\\\$name_uppercase#";
170 $standard_case = preg_match($standard_pattern, $return_doc);
173 $namespace_parts = explode(
"\\", $this->reflection->getNamespaceName());
174 $typediff_only_pattern =
"$regex_head\\\\".array_pop($namespace_parts).
"#";
175 $typediff_only_case = preg_match($typediff_only_pattern, $return_doc);
177 $this->assertTrue($standard_case || $typediff_only_case, $message);
182 return str_replace(
"\\",
"\\\\", $this->reflection->getNamespaceName());
193 $message =
"TODO ($name): remove params from method that returns Factory.";
194 $this->assertEquals(0, $method_reflection->getNumberOfParameters(), $message);
208 if($kitchensink_info_settings[
'description']) {
209 $message =
"TODO ($name): add a description.";
210 $this->assertArrayHasKey(
'description', $docstring_data, $message);
212 $desc_fields = implode(
", ", $this->description_categories);
213 $message =
"TODO ($name): the description field should at least contain one of these: $desc_fields.";
214 $existing_keys = array_keys($docstring_data[
"description"]);
215 $existing_expected_keys = array_intersect($this->description_categories, $existing_keys);
216 $this->assertGreaterThanOrEqual
218 , $existing_expected_keys
231 if($kitchensink_info_settings[
'background']) {
232 $message =
"TODO ($name): add a background field.";
233 $this->assertArrayHasKey(
'background', $docstring_data, $message);
244 if($kitchensink_info_settings[
'featurewiki']) {
245 $message =
"TODO ($name): add a featurewiki field.";
246 $this->assertArrayHasKey(
'featurewiki', $docstring_data, $message);
257 if($kitchensink_info_settings[
'javascript']) {
258 $message =
"TODO ($name): add a javascript field.";
259 $this->assertArrayHasKey(
'javascript' ,$docstring_data, $message);
270 if($kitchensink_info_settings[
'rules']) {
271 $message =
"TODO ($name): add a rules field.";
272 $this->assertArrayHasKey(
'rules', $docstring_data, $message);
274 $rules_fields = implode(
", ", $this->rules_categories);
275 $message =
"TODO ($name): the rules field should at least contain one of these: $rules_fields.";
276 $existing_keys = array_keys($docstring_data[
"rules"]);
277 $existing_expected_keys = array_intersect($this->rules_categories, $existing_keys);
278 $this->assertGreaterThanOrEqual
280 , $existing_expected_keys
295 $message =
"TODO ($name): remove 'context' field, method returns a factory.";
296 $this->assertArrayNotHasKey(
"context", $docstring_data, $message);
299 if ($kitchensink_info_settings[
"context"]) {
300 $message =
"TODO ($name): factory method returning component should have context field. Add it.";
301 $this->assertArrayHasKey(
"context", $docstring_data, $message);
307 if (array_key_exists($name, $this->kitchensink_info_settings)) {
309 ( $this->kitchensink_info_settings_default
310 , $this->kitchensink_info_settings[$name]
test_method_params($method_reflection, $name)
Tests whether methods returning factories have no parameters.
test_return_type($method_reflection, $name)
Tests whether the method either returns a factory or a component.
test_kitchensink_info_context($method_reflection, $name)
methods_provider
test_kitchensink_info_description($method_reflection, $name)
methods_provider
test_check_yaml_extraction($method_reflection, $name)
Tests whether the YAML Kitchen Sink info can be parsed.
test_kitchensink_info_featurewiki($method_reflection, $name)
methods_provider
test_kitchensink_info_javascript($method_reflection, $name)
methods_provider
returnsFactory($docstring_data)
test_factory_method_name_compatible_docstring($method_reflection, $name)
Tests whether the method name matches the.
Defines tests every SHOULD pass UI-factory.
test_kitchensink_info_background($method_reflection, $name)
methods_provider
kitchensink_info_settings_merged_with_defaults($name)
Create styles array
The data for the language used.
test_kitchensink_info_rules($method_reflection, $name)
methods_provider
returnsComponent($docstring_data)
get_regex_factory_namespace()
$kitchensink_info_settings_default