ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 getNumberProvider More...
 
 testNoveltyCounter (int $number)
 getNumberProvider More...
 
 testKnownCountersOnly ()
 
 testIntNumbersOnly ($no_number)
 getNoNumberProvider More...
 
 testRenderStatus (string $type, int $number)
 getCounterTypeAndNumberProvider More...
 

Static Public Member Functions

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

Static Public Attributes

static array $canonical_css_classes
 
static array novelty
 

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().

33  : Factory
34  {
35  return new Factory();
36  }
+ Here is the caller graph for this function:

◆ getCounterTypeAndNumberProvider()

static CounterTest::getCounterTypeAndNumberProvider ( )
static

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  }

◆ getNoNumberProvider()

static CounterTest::getNoNumberProvider ( )
static

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  }

◆ getNumberProvider()

static CounterTest::getNumberProvider ( )
static

Definition at line 92 of file CounterTest.php.

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

◆ testImplementsFactoryInterface()

CounterTest::testImplementsFactoryInterface ( )

Definition at line 38 of file CounterTest.php.

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

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  }
+ Here is the call graph for this function:

◆ testIntNumbersOnly()

CounterTest::testIntNumbersOnly (   $no_number)

getNoNumberProvider

Definition at line 85 of file CounterTest.php.

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

85  : void
86  {
87  $this->expectException(TypeError::class);
88  $f = $this->getCounterFactory();
89  $f->status($no_number);
90  }
+ Here is the call graph for this function:

◆ testKnownCountersOnly()

CounterTest::testKnownCountersOnly ( )

Definition at line 76 of file CounterTest.php.

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

◆ testNoveltyCounter()

CounterTest::testNoveltyCounter ( int  $number)

getNumberProvider

Definition at line 65 of file CounterTest.php.

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

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: deliver.php:25
+ Here is the call graph for this function:

◆ testRenderStatus()

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

getCounterTypeAndNumberProvider

Definition at line 120 of file CounterTest.php.

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

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  }
$c
Definition: deliver.php:25
$r
+ Here is the call graph for this function:

◆ testStatusCounter()

CounterTest::testStatusCounter ( int  $number)

getNumberProvider

Definition at line 51 of file CounterTest.php.

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

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  }
$c
Definition: deliver.php:25
+ 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"

Definition at line 112 of file CounterTest.php.

◆ novelty

array CounterTest::novelty
static
Initial value:
=> "badge badge-notify il-counter-novelty"
]

Definition at line 114 of file CounterTest.php.


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