ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables 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 ()
 
 test_implements_factory_interface ()
 
 test_status_counter ($number)
 number_provider More...
 
 test_novelty_counter ($number)
 number_provider More...
 
 test_known_counters_only ()
 
 test_int_numbers_only ($no_number)
 no_number_provider More...
 
 number_provider ()
 
 no_number_provider ()
 
 test_render_status ($type, $number)
 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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Static Public Attributes

static $canonical_css_classes
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

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.

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

◆ getCounterFactory()

CounterTest::getCounterFactory ( )

Definition at line 15 of file CounterTest.php.

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

16  {
17  return new \ILIAS\UI\Implementation\Component\Counter\Factory();
18  }
+ Here is the caller graph for this function:

◆ no_number_provider()

CounterTest::no_number_provider ( )

Definition at line 83 of file CounterTest.php.

84  {
85  return array( 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.

75  {
76  return array( 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 20 of file CounterTest.php.

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

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

◆ test_int_numbers_only()

CounterTest::test_int_numbers_only (   $no_number)

no_number_provider

Definition at line 67 of file CounterTest.php.

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

68  {
69  $this->expectException(\InvalidArgumentException::class);
70  $f = $this->getCounterFactory();
71  $f->status($no_number);
72  }
+ 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  $this->expectException(\InvalidArgumentException::class);
61  new \ILIAS\UI\Implementation\Component\Counter\Counter("FOO", 1);
62  }

◆ test_novelty_counter()

CounterTest::test_novelty_counter (   $number)

number_provider

Definition at line 47 of file CounterTest.php.

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

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

◆ test_render_status()

CounterTest::test_render_status (   $type,
  $number 
)

counter_type_and_number_provider

Definition at line 99 of file CounterTest.php.

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

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=\"il-counter\"><span class=\"$css_classes\">$number</span></span>";
109  $this->assertHTMLEquals($expected, $html);
110  }
$c
Definition: cli.php:37
$type
normalizeHTML($html)
Definition: Base.php:363
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_status_counter()

CounterTest::test_status_counter (   $number)

number_provider

Definition at line 33 of file CounterTest.php.

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

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  }
$c
Definition: cli.php:37
+ 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: