3 require_once(
"libs/composer/vendor/autoload.php");
51 array(
'purpose',
'composition',
'effect',
'rival');
54 array(
'usage',
'interaction',
'wording',
'style',
'ordering',
'responsiveness',
55 'composition',
'accessibility');
65 return in_array(
"ILIAS\\UI\\Component\\Component", $reflection->getInterfaceNames());
70 return preg_match(
"#^(\\\\)?ILIAS\\\\UI\\\\Component\\\\([a-zA-Z]+\\\\)*Factory$#",
$name) === 1;
81 return array_map(
function ($element) {
82 return array($element, $element->getName());
83 }, $reflection->getMethods());
96 $message =
"TODO: Put your factory into the proper namespace.";
98 "#^ILIAS\\\\UI\\\\Component.#",
99 $this->reflection->getNamespaceName(),
106 $name = $this->reflection->getName();
107 $message =
"TODO: Give your factory a proper name.";
123 $function_name_string =
"\n public function " . $method_reflection->getName() .
"()";
124 $docstring_data = $this->yaml_parser->parseArrayFromString(
125 $method_reflection->getDocComment() . $function_name_string
127 $this->assertTrue(
true);
129 $message =
"TODO ($name): fix parse error in kitchen sink yaml: " . $e->getMessage();
132 $this->assertCount(1, $docstring_data);
133 return $docstring_data[0];
143 $message =
"TODO ($name): fix return type, it must be a factory or a component.";
146 $this->assertTrue(
true);
148 $this->assertTrue(
true);
164 $return_doc = $docstring_data[
"namespace"];
165 $name_uppercase = ucwords(
$name);
167 $regex_head =
"#^(\\\\?)$regex_factory_namespace";
169 $message =
"TODO ($name): fix @return, it does not match the method name.";
172 "$regex_head\\\\$name_uppercase\\\\Factory$#",
179 $standard_pattern =
"$regex_head\\\\$name_uppercase#";
180 $standard_case = preg_match($standard_pattern, $return_doc);
183 $namespace_parts = explode(
"\\", $this->reflection->getNamespaceName());
184 $typediff_only_pattern =
"$regex_head\\\\" . array_pop($namespace_parts) .
"#";
185 $typediff_only_case = preg_match($typediff_only_pattern, $return_doc);
187 $this->assertTrue($standard_case || $typediff_only_case,
$message);
193 return str_replace(
"\\",
"\\\\", $this->reflection->getNamespaceName());
205 $message =
"TODO ($name): remove params from method that returns Factory.";
206 $this->assertEquals(0, $method_reflection->getNumberOfParameters(),
$message);
221 if ($kitchensink_info_settings[
'description']) {
222 $message =
"TODO ($name): add a description.";
223 $this->assertArrayHasKey(
'description', $docstring_data,
$message);
225 $desc_fields = implode(
", ", $this->description_categories);
226 $message =
"TODO ($name): the description field should at least contain one of these: $desc_fields.";
227 $existing_keys = array_keys($docstring_data[
"description"]);
228 $existing_expected_keys = array_intersect($this->description_categories, $existing_keys);
229 $this->assertGreaterThanOrEqual(
231 $existing_expected_keys,
243 if (isset($docstring_data[
"description"]) && isset($docstring_data[
"description"][
"rivals"])) {
244 $rules = $docstring_data[
"description"][
"rivals"];
245 $message =
"TODO ($name): The Rivals field has a non-string index. Format like 'rival_name': 'description'";
246 $this->assertTrue(array_unique(array_map(
"is_string", array_keys($rules))) === array(
true),
$message);
248 $this->assertTrue(
true);
259 if ($kitchensink_info_settings[
'background']) {
260 $message =
"TODO ($name): add a background field.";
261 $this->assertArrayHasKey(
'background', $docstring_data,
$message);
273 if ($kitchensink_info_settings[
'featurewiki']) {
274 $message =
"TODO ($name): add a featurewiki field.";
275 $this->assertArrayHasKey(
'featurewiki', $docstring_data,
$message);
287 if ($kitchensink_info_settings[
'javascript']) {
288 $message =
"TODO ($name): add a javascript field.";
289 $this->assertArrayHasKey(
'javascript', $docstring_data,
$message);
301 if ($kitchensink_info_settings[
'rules']) {
302 $message =
"TODO ($name): add a rules field.";
303 $this->assertArrayHasKey(
'rules', $docstring_data,
$message);
305 $rules_fields = implode(
", ", $this->rules_categories);
306 $message =
"TODO ($name): the rules field should at least contain one of these: $rules_fields.";
307 $existing_keys = array_keys($docstring_data[
"rules"]);
308 $existing_expected_keys = array_intersect($this->rules_categories, $existing_keys);
309 $this->assertGreaterThanOrEqual(
311 $existing_expected_keys,
327 $message =
"TODO ($name): remove 'context' field, method returns a factory.";
328 $this->assertArrayNotHasKey(
"context", $docstring_data,
$message);
330 if ($kitchensink_info_settings[
"context"]) {
331 $message =
"TODO ($name): factory method returning component should have context field. Add it.";
332 $this->assertArrayHasKey(
"context", $docstring_data,
$message);
339 if (array_key_exists(
$name, $this->kitchensink_info_settings)) {
341 $this->kitchensink_info_settings_default,
342 $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)
test_kitchensink_info_rules($method_reflection, $name)
methods_provider
returnsComponent($docstring_data)
get_regex_factory_namespace()
$kitchensink_info_settings_default
test_kitchensink_info_rivals($method_reflection, $name)
methods_provider