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