ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
DimensionTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once('./vendor/composer/vendor/autoload.php');
22 
25 
26 class DimensionTest extends TestCase
27 {
28  protected Dimension\Factory $f;
29 
30  protected function setUp(): void
31  {
32  $this->f = new Dimension\Factory();
33  }
34 
35  public function testCardinaltLabels(): void
36  {
37  $labels = ["label1", "label2", "label3"];
38  $c = $this->f->cardinal($labels);
39  $this->assertEquals($labels, $c->getLabels());
40  }
41 
42  public function testRangeLabels(): void
43  {
44  $labels = ["label1", "label2", "label3"];
45  $c = $this->f->cardinal($labels);
46  $r = $this->f->range($c);
47  $this->assertEquals($labels, $r->getLabels());
48  $this->assertEquals($c->getLabels(), $r->getLabels());
49  }
50 
51  public function testCardinalNumericValues(): void
52  {
53  try {
54  $c = $this->f->cardinal();
55  $c->checkValue(-2);
56  $c->checkValue(0);
57  $c->checkValue(0.5);
58  $c->checkValue("1.5");
59  $this->assertTrue(true);
60  } catch (\InvalidArgumentException $e) {
61  $this->assertFalse("This should not happen.");
62  }
63  }
64 
65  public function testCardinalNullValue(): void
66  {
67  try {
68  $c = $this->f->cardinal();
69  $c->checkValue(null);
70  $this->assertTrue(true);
71  } catch (\InvalidArgumentException $e) {
72  $this->assertFalse("This should not happen.");
73  }
74  }
75 
76  public function testCardinalInvalidValue(): void
77  {
78  try {
79  $c = $this->f->cardinal();
80  $c->checkValue("A value");
81  $this->assertFalse("This should not happen.");
82  } catch (\InvalidArgumentException $e) {
83  $this->assertTrue(true);
84  }
85  }
86 
87  public function testRangeNullValue(): void
88  {
89  try {
90  $c = $this->f->cardinal();
91  $r = $this->f->range($c);
92  $r->checkValue(null);
93  $this->assertTrue(true);
94  } catch (\InvalidArgumentException $e) {
95  $this->assertFalse("This should not happen.");
96  }
97  }
98 
99  public function testRangeNumericValues(): void
100  {
101  try {
102  $c = $this->f->cardinal();
103  $r = $this->f->range($c);
104  $r->checkValue([-2, 0]);
105  $r->checkValue([0.5, "1.5"]);
106  $this->assertTrue(true);
107  } catch (\InvalidArgumentException $e) {
108  $this->assertFalse("This should not happen.");
109  }
110  }
111 
112  public function testRangeInvalidArray(): void
113  {
114  try {
115  $c = $this->f->cardinal();
116  $r = $this->f->range($c);
117  $r->checkValue(2);
118  $this->assertFalse("This should not happen.");
119  } catch (\InvalidArgumentException $e) {
120  $this->assertTrue(true);
121  }
122  }
123 
124  public function testRangeInvalidCount(): void
125  {
126  try {
127  $c = $this->f->cardinal();
128  $r = $this->f->range($c);
129  $r->checkValue([2]);
130  $this->assertFalse("This should not happen.");
131  } catch (\InvalidArgumentException $e) {
132  $this->assertTrue(true);
133  }
134  }
135 
136  public function testRangeInvalidValues(): void
137  {
138  try {
139  $c = $this->f->cardinal();
140  $r = $this->f->range($c);
141  $r->checkValue([2, "A value"]);
142  $this->assertFalse("This should not happen.");
143  } catch (\InvalidArgumentException $e) {
144  $this->assertTrue(true);
145  }
146  }
147 }
Dimension Factory $f
$c
Definition: deliver.php:25
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$r