ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ($number)
 @dataProvider number_provider More...
 
 test_novelty_counter ($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 ($type, $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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Static Public Attributes

static $canonical_css_classes
 

Detailed Description

Defines tests that a counter implementation should pass.

Definition at line 13 of file CounterTest.php.

Member Function Documentation

◆ counter_type_and_number_provider()

CounterTest::counter_type_and_number_provider ( )

Definition at line 119 of file CounterTest.php.

120 {
121 return array( array("status", 42)
122 , array("novelty", 13)
123 , array("status", 1)
124 , array("novelty", 23)
125 );
126 }

◆ getCounterFactory()

CounterTest::getCounterFactory ( )

Definition at line 15 of file CounterTest.php.

16 {
17 return new \ILIAS\UI\Implementation\Component\Counter\Factory();
18 }

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

91 {
92 return array( array("foo")
93 , array(9.1)
94 , array(array())
95 , array(new stdClass())
96 );
97 }

◆ number_provider()

CounterTest::number_provider ( )

Definition at line 81 of file CounterTest.php.

82 {
83 return array( array(-13)
84 , array(0)
85 , array(23)
86 , array(42)
87 );
88 }

◆ test_implements_factory_interface()

CounterTest::test_implements_factory_interface ( )

Definition at line 20 of file CounterTest.php.

21 {
22 $f = $this->getCounterFactory();
23
24 $this->assertInstanceOf("ILIAS\\UI\\Component\\Counter\\Factory", $f);
25
26 $this->assertInstanceOf("ILIAS\\UI\\Component\\Counter\\Counter", $f->status(0));
27 $this->assertInstanceOf("ILIAS\\UI\\Component\\Counter\\Counter", $f->novelty(0));
28 }

References $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 70 of file CounterTest.php.

71 {
72 $f = $this->getCounterFactory();
73
74 try {
75 $f->status($no_number);
76 $this->assertFalse("This should not happen");
77 } catch (\InvalidArgumentException $e) {
78 }
79 }

References $f, and getCounterFactory().

+ Here is the call graph for this function:

◆ test_known_counters_only()

CounterTest::test_known_counters_only ( )

Definition at line 58 of file CounterTest.php.

59 {
60 try {
61 new \ILIAS\UI\Implementation\Component\Counter\Counter("FOO", 1);
62 $this->assertFalse("We should not get here");
63 } catch (\InvalidArgumentException $e) {
64 }
65 }

◆ test_novelty_counter()

CounterTest::test_novelty_counter (   $number)

@dataProvider number_provider

Definition at line 47 of file CounterTest.php.

48 {
49 $f = $this->getCounterFactory();
50
51 $c = $f->novelty($number);
52
53 $this->assertNotNull($c);
54 $this->assertEquals(C\Counter\Counter::NOVELTY, $c->getType());
55 $this->assertEquals($number, $c->getNumber());
56 }

References $c, $f, and getCounterFactory().

+ Here is the call graph for this function:

◆ test_render_status()

CounterTest::test_render_status (   $type,
  $number 
)

@dataProvider counter_type_and_number_provider

Definition at line 106 of file CounterTest.php.

107 {
108 $f = $this->getCounterFactory();
109 $r = $this->getDefaultRenderer();
110 $c = $f->$type($number);
111
112 $html = $this->normalizeHTML($r->render($c));
113
114 $css_classes = self::$canonical_css_classes[$type];
115 $expected = "<span class=\"$css_classes\">$number</span>";
116 $this->assertEquals($expected, $html);
117 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: Base.php:261
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79
$type

References $c, $f, $html, $r, $type, 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 (   $number)

@dataProvider number_provider

Definition at line 33 of file CounterTest.php.

34 {
35 $f = $this->getCounterFactory();
36
37 $c = $f->status($number);
38
39 $this->assertNotNull($c);
40 $this->assertEquals(C\Counter\Counter::STATUS, $c->getType());
41 $this->assertEquals($number, $c->getNumber());
42 }

References $c, $f, and getCounterFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $canonical_css_classes

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

Definition at line 99 of file CounterTest.php.


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