ILIAS  release_8 Revision v8.24
CounterTest Class Reference

Defines tests that a counter implementation should pass. More...

+ Inheritance diagram for CounterTest:
+ Collaboration diagram for CounterTest:

Public Member Functions

 getCounterFactory ()
 
 test_implements_factory_interface ()
 
 test_status_counter (int $number)
 @dataProvider number_provider More...
 
 test_novelty_counter (int $number)
 @dataProvider number_provider More...
 
 test_known_counters_only ()
 
 test_int_numbers_only ($no_number)
 @dataProvider no_number_provider More...
 
 number_provider ()
 
 no_number_provider ()
 
 test_render_status (string $type, int $number)
 @dataProvider counter_type_and_number_provider More...
 
 counter_type_and_number_provider ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Static Public Attributes

static array $canonical_css_classes
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Defines tests that a counter implementation should pass.

Definition at line 31 of file CounterTest.php.

Member Function Documentation

◆ counter_type_and_number_provider()

CounterTest::counter_type_and_number_provider ( )

Definition at line 133 of file CounterTest.php.

133 : array
134 {
135 return [
136 ["status", 42],
137 ["novelty", 13],
138 ["status", 1],
139 ["novelty", 23],
140 ];
141 }

◆ getCounterFactory()

CounterTest::getCounterFactory ( )

Definition at line 33 of file CounterTest.php.

Referenced by test_implements_factory_interface(), test_int_numbers_only(), test_novelty_counter(), test_render_status(), and test_status_counter().

+ Here is the caller graph for this function:

◆ no_number_provider()

CounterTest::no_number_provider ( )

Definition at line 102 of file CounterTest.php.

102 : array
103 {
104 return [
105 ["foo"],
106 [9.1],
107 [array()],
108 [new stdClass()]
109 ];
110 }

◆ number_provider()

CounterTest::number_provider ( )

Definition at line 92 of file CounterTest.php.

92 : array
93 {
94 return [
95 [-13],
96 [0],
97 [23],
98 [4]
99 ];
100 }

◆ test_implements_factory_interface()

CounterTest::test_implements_factory_interface ( )

Definition at line 38 of file CounterTest.php.

38 : void
39 {
40 $f = $this->getCounterFactory();
41
42 $this->assertInstanceOf("ILIAS\\UI\\Component\\Counter\\Factory", $f);
43
44 $this->assertInstanceOf("ILIAS\\UI\\Component\\Counter\\Counter", $f->status(0));
45 $this->assertInstanceOf("ILIAS\\UI\\Component\\Counter\\Counter", $f->novelty(0));
46 }

References Vendor\Package\$f, and getCounterFactory().

+ Here is the call graph for this function:

◆ test_int_numbers_only()

CounterTest::test_int_numbers_only (   $no_number)

@dataProvider no_number_provider

Definition at line 85 of file CounterTest.php.

85 : void
86 {
87 $this->expectException(TypeError::class);
88 $f = $this->getCounterFactory();
89 $f->status($no_number);
90 }

References Vendor\Package\$f, and getCounterFactory().

+ Here is the call graph for this function:

◆ test_known_counters_only()

CounterTest::test_known_counters_only ( )

Definition at line 76 of file CounterTest.php.

76 : void
77 {
78 $this->expectException(InvalidArgumentException::class);
79 new Counter("FOO", 1);
80 }

◆ test_novelty_counter()

CounterTest::test_novelty_counter ( int  $number)

@dataProvider number_provider

Definition at line 65 of file CounterTest.php.

65 : void
66 {
67 $f = $this->getCounterFactory();
68
69 $c = $f->novelty($number);
70
71 $this->assertNotNull($c);
72 $this->assertEquals(C\Counter\Counter::NOVELTY, $c->getType());
73 $this->assertEquals($number, $c->getNumber());
74 }
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $c, Vendor\Package\$f, and getCounterFactory().

+ Here is the call graph for this function:

◆ test_render_status()

CounterTest::test_render_status ( string  $type,
int  $number 
)

@dataProvider counter_type_and_number_provider

Definition at line 120 of file CounterTest.php.

120 : void
121 {
122 $f = $this->getCounterFactory();
123 $r = $this->getDefaultRenderer();
124 $c = $f->$type($number);
125
126 $html = $this->normalizeHTML($r->render($c));
127
128 $css_classes = self::$canonical_css_classes[$type];
129 $expected = "<span class=\"il-counter\"><span class=\"$css_classes\">$number</span></span>";
130 $this->assertHTMLEquals($expected, $html);
131 }
normalizeHTML(string $html)
Definition: Base.php:422
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
$type

References $c, Vendor\Package\$f, $type, ILIAS_UI_TestBase\assertHTMLEquals(), getCounterFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

◆ test_status_counter()

CounterTest::test_status_counter ( int  $number)

@dataProvider number_provider

Definition at line 51 of file CounterTest.php.

51 : void
52 {
53 $f = $this->getCounterFactory();
54
55 $c = $f->status($number);
56
57 $this->assertNotNull($c);
58 $this->assertEquals(C\Counter\Counter::STATUS, $c->getType());
59 $this->assertEquals($number, $c->getNumber());
60 }

References $c, Vendor\Package\$f, and getCounterFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $canonical_css_classes

array CounterTest::$canonical_css_classes
static
Initial value:
= [
"status" => "badge badge-notify il-counter-status",
"novelty" => "badge badge-notify il-counter-novelty"
]

Definition at line 112 of file CounterTest.php.


The documentation for this class was generated from the following file: