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');
63 return in_array(
"ILIAS\\UI\\Component\\Component", $reflection->getInterfaceNames());
68 return preg_match(
"#^(\\\\)?ILIAS\\\\UI\\\\Component\\\\([a-zA-Z]+\\\\)*Factory$#",
$name) === 1;
79 return array_map(
function ($element) {
80 return array($element, $element->getName());
81 }, $reflection->getMethods());
94 $message =
"TODO: Put your factory into the proper namespace.";
96 "#^ILIAS\\\\UI\\\\Component.#",
97 $this->reflection->getNamespaceName(),
104 $name = $this->reflection->getName();
105 $message =
"TODO: Give your factory a proper name.";
121 $function_name_string =
"\n public function " . $method_reflection->getName() .
"()";
122 $docstring_data = $this->yaml_parser->parseArrayFromString(
123 $method_reflection->getDocComment() . $function_name_string
125 $this->assertTrue(
true);
127 $message =
"TODO ($name): fix parse error in kitchen sink yaml: " . $e->getMessage();
130 $this->assertCount(1, $docstring_data);
131 return $docstring_data[0];
141 $message =
"TODO ($name): fix return type, it must be a factory or a component.";
144 $this->assertTrue(
true);
146 $this->assertTrue(
true);
162 $return_doc = $docstring_data[
"namespace"];
163 $name_uppercase = ucwords(
$name);
165 $regex_head =
"#^(\\\\?)$regex_factory_namespace";
167 $message =
"TODO ($name): fix @return, it does not match the method name.";
170 "$regex_head\\\\$name_uppercase\\\\Factory$#",
177 $standard_pattern =
"$regex_head\\\\$name_uppercase#";
178 $standard_case = preg_match($standard_pattern, $return_doc);
181 $namespace_parts = explode(
"\\", $this->reflection->getNamespaceName());
182 $typediff_only_pattern =
"$regex_head\\\\" . array_pop($namespace_parts) .
"#";
183 $typediff_only_case = preg_match($typediff_only_pattern, $return_doc);
185 $this->assertTrue($standard_case || $typediff_only_case,
$message);
191 return str_replace(
"\\",
"\\\\", $this->reflection->getNamespaceName());
203 $message =
"TODO ($name): remove params from method that returns Factory.";
204 $this->assertEquals(0, $method_reflection->getNumberOfParameters(),
$message);
219 if ($kitchensink_info_settings[
'description']) {
220 $message =
"TODO ($name): add a description.";
221 $this->assertArrayHasKey(
'description', $docstring_data,
$message);
223 $desc_fields = implode(
", ", $this->description_categories);
224 $message =
"TODO ($name): the description field should at least contain one of these: $desc_fields.";
225 $existing_keys = array_keys($docstring_data[
"description"]);
226 $existing_expected_keys = array_intersect($this->description_categories, $existing_keys);
227 $this->assertGreaterThanOrEqual(
229 $existing_expected_keys,
243 if ($kitchensink_info_settings[
'background']) {
244 $message =
"TODO ($name): add a background field.";
245 $this->assertArrayHasKey(
'background', $docstring_data,
$message);
257 if ($kitchensink_info_settings[
'featurewiki']) {
258 $message =
"TODO ($name): add a featurewiki field.";
259 $this->assertArrayHasKey(
'featurewiki', $docstring_data,
$message);
271 if ($kitchensink_info_settings[
'javascript']) {
272 $message =
"TODO ($name): add a javascript field.";
273 $this->assertArrayHasKey(
'javascript', $docstring_data,
$message);
285 if ($kitchensink_info_settings[
'rules']) {
286 $message =
"TODO ($name): add a rules field.";
287 $this->assertArrayHasKey(
'rules', $docstring_data,
$message);
289 $rules_fields = implode(
", ", $this->rules_categories);
290 $message =
"TODO ($name): the rules field should at least contain one of these: $rules_fields.";
291 $existing_keys = array_keys($docstring_data[
"rules"]);
292 $existing_expected_keys = array_intersect($this->rules_categories, $existing_keys);
293 $this->assertGreaterThanOrEqual(
295 $existing_expected_keys,
311 $message =
"TODO ($name): remove 'context' field, method returns a factory.";
312 $this->assertArrayNotHasKey(
"context", $docstring_data,
$message);
314 if ($kitchensink_info_settings[
"context"]) {
315 $message =
"TODO ($name): factory method returning component should have context field. Add it.";
316 $this->assertArrayHasKey(
"context", $docstring_data,
$message);
323 if (array_key_exists(
$name, $this->kitchensink_info_settings)) {
325 $this->kitchensink_info_settings_default,
326 $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.
catch(Exception $e) $message
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