ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CounterTest Class Reference

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

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

Public Member Functions

 getCounterFactory ()
 
 testImplementsFactoryInterface ()
 
 testStatusCounter (int $number)
 
 testNoveltyCounter (int $number)
 
 testKnownCountersOnly ()
 
 testIntNumbersOnly ($no_number)
 
 testRenderStatus (string $type, int $number)
 

Static Public Member Functions

static getNumberProvider ()
 
static getNoNumberProvider ()
 
static getCounterTypeAndNumberProvider ()
 

Static Public Attributes

static array $canonical_css_classes
 

Detailed Description

Defines tests that a counter implementation should pass.

Definition at line 31 of file CounterTest.php.

Member Function Documentation

◆ getCounterFactory()

CounterTest::getCounterFactory ( )

Definition at line 33 of file CounterTest.php.

Referenced by testImplementsFactoryInterface(), testIntNumbersOnly(), testNoveltyCounter(), testRenderStatus(), and testStatusCounter().

+ Here is the caller graph for this function:

◆ getCounterTypeAndNumberProvider()

static CounterTest::getCounterTypeAndNumberProvider ( )
static

Definition at line 125 of file CounterTest.php.

125 : array
126 {
127 return [
128 ["status", 42],
129 ["novelty", 13],
130 ["status", 1],
131 ["novelty", 23],
132 ];
133 }

◆ getNoNumberProvider()

static CounterTest::getNoNumberProvider ( )
static

Definition at line 96 of file CounterTest.php.

96 : array
97 {
98 return [
99 ["foo"],
100 [9.1],
101 [array()],
102 [new stdClass()]
103 ];
104 }

◆ getNumberProvider()

static CounterTest::getNumberProvider ( )
static

Definition at line 86 of file CounterTest.php.

86 : array
87 {
88 return [
89 [-13],
90 [0],
91 [23],
92 [4]
93 ];
94 }

◆ testImplementsFactoryInterface()

CounterTest::testImplementsFactoryInterface ( )

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:

◆ testIntNumbersOnly()

CounterTest::testIntNumbersOnly (   $no_number)

Definition at line 79 of file CounterTest.php.

79 : void
80 {
81 $this->expectException(TypeError::class);
82 $f = $this->getCounterFactory();
83 $f->status($no_number);
84 }

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

+ Here is the call graph for this function:

◆ testKnownCountersOnly()

CounterTest::testKnownCountersOnly ( )

Definition at line 72 of file CounterTest.php.

72 : void
73 {
74 $this->expectException(InvalidArgumentException::class);
75 new Counter("FOO", 1);
76 }

◆ testNoveltyCounter()

CounterTest::testNoveltyCounter ( int  $number)

Definition at line 61 of file CounterTest.php.

61 : void
62 {
63 $f = $this->getCounterFactory();
64
65 $c = $f->novelty($number);
66
67 $this->assertNotNull($c);
68 $this->assertEquals(C\Counter\Counter::NOVELTY, $c->getType());
69 $this->assertEquals($number, $c->getNumber());
70 }
$c
Definition: deliver.php:25

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

+ Here is the call graph for this function:

◆ testRenderStatus()

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

Definition at line 112 of file CounterTest.php.

112 : void
113 {
114 $f = $this->getCounterFactory();
115 $r = $this->getDefaultRenderer();
116 $c = $f->$type($number);
117
118 $html = $this->normalizeHTML($r->render($c));
119
120 $css_classes = self::$canonical_css_classes[$type];
121 $expected = "<span class=\"il-counter\"><span class=\"$css_classes\">$number</span></span>";
122 $this->assertHTMLEquals($expected, $html);
123 }

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

+ Here is the call graph for this function:

◆ testStatusCounter()

CounterTest::testStatusCounter ( int  $number)

Definition at line 49 of file CounterTest.php.

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

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 106 of file CounterTest.php.


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