ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 
 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 112 of file CounterTest.php.

112 {
113 return array
114 ( array("status", 42)
115 , array("novelty", 13)
116 , array("status", 1)
117 , array("novelty", 23)
118 );
119 }

◆ getCounterFactory()

CounterTest::getCounterFactory ( )

Definition at line 14 of file CounterTest.php.

14 {
15 return new \ILIAS\UI\Implementation\Component\Counter\Factory();
16 }

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

83 {
84 return array
85 ( array("foo")
86 , array(9.1)
87 , array(array())
88 , array(new stdClass())
89 );
90 }

◆ number_provider()

CounterTest::number_provider ( )

Definition at line 74 of file CounterTest.php.

74 {
75 return array
76 ( array(-13)
77 , array(0)
78 , array(23)
79 , array(42)
80 );
81 }

◆ test_implements_factory_interface()

CounterTest::test_implements_factory_interface ( )

Definition at line 18 of file CounterTest.php.

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

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

64 {
65 $f = $this->getCounterFactory();
66
67 try {
68 $f->status($no_number);
69 $this->assertFalse("This should not happen");
70 }
71 catch (\InvalidArgumentException $e) {}
72 }

References getCounterFactory().

+ Here is the call graph for this function:

◆ test_known_counters_only()

CounterTest::test_known_counters_only ( )

Definition at line 53 of file CounterTest.php.

53 {
54 try {
55 new \ILIAS\UI\Implementation\Component\Counter\Counter("FOO", 1);
56 $this->assertFalse("We should not get here");
57 }
58 catch (\InvalidArgumentException $e) {}
59 }

◆ test_novelty_counter()

CounterTest::test_novelty_counter (   $number)

@dataProvider number_provider

Definition at line 43 of file CounterTest.php.

43 {
44 $f = $this->getCounterFactory();
45
46 $c = $f->novelty($number);
47
48 $this->assertNotNull($c);
49 $this->assertEquals(C\Counter\Counter::NOVELTY, $c->getType());
50 $this->assertEquals($number, $c->getNumber());
51 }

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

100 {
101 $f = $this->getCounterFactory();
102 $r = $this->getDefaultRenderer();
103 $c = $f->$type($number);
104
105 $html = $this->normalizeHTML($r->render($c));
106
107 $css_classes = self::$canonical_css_classes[$type];
108 $expected = "<span class=\"$css_classes\">$number</span>";
109 $this->assertEquals($expected, $html);
110 }
normalizeHTML($html)
Definition: Base.php:110
getDefaultRenderer()
Definition: Base.php:100
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79

References $html, $r, 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 30 of file CounterTest.php.

30 {
31 $f = $this->getCounterFactory();
32
33 $c = $f->status($number);
34
35 $this->assertNotNull($c);
36 $this->assertEquals(C\Counter\Counter::STATUS, $c->getType());
37 $this->assertEquals($number, $c->getNumber());
38 }

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


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