ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ComponentEntryRulesTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
3 
4 require_once("libs/composer/vendor/autoload.php");
5 include_once("tests/UI/Crawler/Fixture/Fixture.php");
6 
9 
11 {
13  "usage"=>array(),
14  "composition"=>array(),
15  "interaction"=>array(),
16  "wording"=>array(),
17  "ordering"=>array(),
18  "style"=>array(),
19  "responsiveness"=>array(),
20  "accessibility"=>array()
21  );
23  "usage",
24  "wrong"
25  );
27  "usage"=>array(),
28  "wrong"=>array()
29  );
31  "usage"=>array("Correct"),
32  "composition"=>"Wrong"
33  );
35  "usage"=>array("Correct"),
36  "composition"=>array(array("wrong"))
37  );
39  "usage"=>array(1 => "Usage Rule 1", 2 => "Usage Rule 2"),
40  "composition"=>array(1 => "composition Rule 1", 2 => "composition Rule 2"),
41  "interaction"=>array(1 => "interaction Rule 1", 2 => "interaction Rule 2"),
42  "wording"=>array(1 => "wording Rule 1", 2 => "wording Rule 2"),
43  "ordering"=>array(1 => "ordering Rule 1", 2 => "ordering Rule 2"),
44  "style"=>array(1 => "style Rule 1", 2 => "style Rule 2"),
45  "responsiveness"=>array(1 => "responsiveness Rule 1", 2 => "responsiveness Rule 2"),
46  "accessibility"=>array(1 => "accessibility Rule 1", 2 => "accessibility Rule 2")
47  );
49  "usage"=>array(1 => "Usage Rule 1", 2 => "Usage Rule 2"),
50  "accessibility"=>""
51  );
53  "usage"=>array(1 => "Usage Rule 1", 2 => "Usage Rule 2"),
54  "composition"=>array(),
55  "interaction"=>array(),
56  "wording"=>array(),
57  "ordering"=>array(),
58  "style"=>array(),
59  "responsiveness"=>array(),
60  "accessibility"=>array()
61  );
62 
66  protected $parser;
67 
71  protected $proper_entry;
72 
73  protected function setUp()
74  {
75  $this->parser = new Crawler\EntriesYamlParser();
76  $this->proper_entry = new ProperEntryFixture();
77  }
78 
79 
83  public function testEmptyRules()
84  {
86  $this->assertEquals($this->empty_rules_array, $rule->getRules());
87 
89  $this->assertEquals($this->empty_rules_array, $rule->getRules());
90  }
94  public function testInvalidRules()
95  {
96  try {
97  new Entry\ComponentEntryRules(null);
98  new Entry\ComponentEntryRules("rule1");
99  $this->assertFalse("This should not happen");
100  } catch (Crawler\Exception\CrawlerException $e) {
101  $this->assertEquals($e->getCode(), Crawler\Exception\CrawlerException::ARRAY_EXPECTED);
102  }
103  }
107  public function testInvalidCategories1()
108  {
109  try {
110  new Entry\ComponentEntryRules($this->invalid_categories1_array);
111  $this->assertFalse("This should not happen");
112  } catch (Crawler\Exception\CrawlerException $e) {
113  $this->assertEquals($e->getCode(), Crawler\Exception\CrawlerException::INVALID_INDEX);
114  }
115  }
119  public function testInvalidCategories2()
120  {
121  try {
122  new Entry\ComponentEntryRules($this->invalid_categories2_array);
123  $this->assertFalse("This should not happen");
124  } catch (Crawler\Exception\CrawlerException $e) {
125  $this->assertEquals($e->getCode(), Crawler\Exception\CrawlerException::INVALID_INDEX);
126  }
127  }
131  public function testInvalidCategoryItem()
132  {
133  try {
134  new Entry\ComponentEntryRules($this->invalid_category_item_array);
135  $this->assertFalse("This should not happen");
136  } catch (Crawler\Exception\CrawlerException $e) {
137  $this->assertEquals($e->getCode(), Crawler\Exception\CrawlerException::ARRAY_EXPECTED);
138  }
139  }
143  public function testInvalidCategoryValue()
144  {
145  try {
146  new Entry\ComponentEntryRules($this->invalid_category_value_array);
147  $this->assertFalse("This should not happen");
148  } catch (Crawler\Exception\CrawlerException $e) {
149  $this->assertEquals($e->getCode(), Crawler\Exception\CrawlerException::STRING_EXPECTED);
150  }
151  }
155  public function testCorrectRules1()
156  {
157  $rules = new Entry\ComponentEntryRules($this->correct_rules1_array);
158  $this->assertEquals($this->correct_rules1_array, $rules->getRules());
159  }
160 
164  public function testCorrectRules2()
165  {
166  $rules = new Entry\ComponentEntryRules($this->correct_rules2_array);
167  $this->assertEquals($this->correct_rules2_array_return, $rules->getRules());
168  }
169 
170  public function testParseProperEntryToArray()
171  {
172  $entry = $this->parser->parseArrayFromFile("tests/UI/Crawler/Fixture/ProperEntry.php")[0];
173 
174  $entry["rules"]['composition'] = array();
175  $entry["rules"]['interaction'] = array();
176  $entry["rules"]['wording'] = array();
177  $entry["rules"]['ordering'] = array();
178  $entry["rules"]['responsiveness'] = array();
179  $entry["rules"]['accessibility'] = array();
180 
181  $rules = new Entry\ComponentEntryRules($entry["rules"]);
182  $this->assertEquals($rules->getRules(), $entry["rules"]);
183  }
184 }
$rule
Definition: showstats.php:43
Create styles array
The data for the language used.