ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLPStatusIconsTest Class Reference

Unit tests for class ilLPStatusIcons. More...

+ Inheritance diagram for ilLPStatusIconsTest:
+ Collaboration diagram for ilLPStatusIconsTest:

Public Member Functions

 testTripleton ()
 
 testGetInstanceForInvalidVariant ()
 
 testSomeExamplesForImagePathsByStatus (array $instances)
 testTripleton More...
 
 testImagePathRunningForLongVariant (array $instances)
 testTripleton More...
 
 testImagePathAssetForLongVariant (array $instances)
 testTripleton More...
 
 testSomeExamplesForRenderedIcons (array $instances)
 testTripleton More...
 
 testRenderScormIcons (array $instances)
 testTripleton More...
 

Protected Member Functions

 getUIFactory ()
 
 getUIRenderer ()
 

Protected Attributes

 $path = 'sample/path'
 
 $alt = 'alt'
 
 $size = Icon::SMALL
 

Detailed Description

Unit tests for class ilLPStatusIcons.

Author
Tim Schmitz schmi.nosp@m.tz@l.nosp@m.eifos.nosp@m..com

Definition at line 33 of file ilLPStatusIconsTest.php.

Member Function Documentation

◆ getUIFactory()

ilLPStatusIconsTest::getUIFactory ( )
protected

Definition at line 39 of file ilLPStatusIconsTest.php.

Referenced by testTripleton().

39  : UIFactory
40  {
41  $custom_icon = $this->createMock(Custom::class);
42  $custom_icon->method('getIconPath')
43  ->willReturn($this->path);
44  $custom_icon->method('getSize')
45  ->willReturn($this->size);
46  $custom_icon->method('getLabel')
47  ->willReturn($this->alt);
48 
49  $icon_factory = $this->createMock(IconFactory::class);
50  $icon_factory->method('custom')
51  ->willReturn($custom_icon);
52 
53  $symbol_factory = $this->createMock(SymbolFactory::class);
54  $symbol_factory->method('icon')
55  ->willReturn($icon_factory);
56 
57  $factory = $this->createMock(UIFactory::class);
58  $factory->method('symbol')
59  ->willReturn($symbol_factory);
60 
61  return $factory;
62  }
+ Here is the caller graph for this function:

◆ getUIRenderer()

ilLPStatusIconsTest::getUIRenderer ( )
protected

Definition at line 64 of file ilLPStatusIconsTest.php.

References $renderer.

Referenced by testTripleton().

64  : UIRenderer
65  {
66  $renderer = $this->createMock(UIRenderer::class);
67  $renderer->method('render')
68  ->willReturnCallback(function ($arg) {
69  return 'rendered: path(' . $arg->getIconPath() .
70  '), alt(' . $arg->getLabel() .
71  '), size(' . $arg->getSize() . ')';
72  });
73 
74  return $renderer;
75  }
$renderer
+ Here is the caller graph for this function:

◆ testGetInstanceForInvalidVariant()

ilLPStatusIconsTest::testGetInstanceForInvalidVariant ( )

Definition at line 105 of file ilLPStatusIconsTest.php.

References $renderer, and ilLPStatusIcons\getInstance().

105  : void
106  {
107  $renderer = $this->getMockBuilder(UIRenderer::class)
108  ->disableOriginalConstructor()
109  ->getMock();
110 
111  $factory = $this->getMockBuilder(UIFactory::class)
112  ->disableOriginalConstructor()
113  ->getMock();
114 
115  $this->expectException(ilLPException::class);
116  ilLPStatusIcons::getInstance(793, $renderer, $factory);
117  }
$renderer
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
+ Here is the call graph for this function:

◆ testImagePathAssetForLongVariant()

ilLPStatusIconsTest::testImagePathAssetForLongVariant ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 152 of file ilLPStatusIconsTest.php.

152  : void
153  {
154  $this->expectException(ilLPException::class);
155  $instances['long']->getImagePathAsset();
156  }

◆ testImagePathRunningForLongVariant()

ilLPStatusIconsTest::testImagePathRunningForLongVariant ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 142 of file ilLPStatusIconsTest.php.

142  : void
143  {
144  $this->expectException(ilLPException::class);
145  $instances['long']->getImagePathRunning();
146  }

◆ testRenderScormIcons()

ilLPStatusIconsTest::testRenderScormIcons ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 184 of file ilLPStatusIconsTest.php.

184  : void
185  {
186  $this->expectException(ilLPException::class);
187  $instances['scorm']->renderIcon('path', 'alt');
188  }

◆ testSomeExamplesForImagePathsByStatus()

ilLPStatusIconsTest::testSomeExamplesForImagePathsByStatus ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 123 of file ilLPStatusIconsTest.php.

References ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED_NUM, and ilLPStatus\LP_STATUS_IN_PROGRESS_NUM.

123  : void
124  {
125  $path1 = $instances['long']->getImagePathInProgress();
126  $path2 = $instances['long']->getImagePathForStatus(ilLPStatus::LP_STATUS_IN_PROGRESS_NUM);
127  $this->assertSame($path1, $path2);
128 
129  $path1 = $instances['short']->getImagePathCompleted();
130  $path2 = $instances['short']->getImagePathForStatus(ilLPStatus::LP_STATUS_COMPLETED_NUM);
131  $this->assertSame($path1, $path2);
132 
133  $path1 = $instances['scorm']->getImagePathFailed();
134  $path2 = $instances['scorm']->getImagePathForStatus(ilLPStatus::LP_STATUS_FAILED_NUM);
135  $this->assertSame($path1, $path2);
136  }
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_FAILED_NUM

◆ testSomeExamplesForRenderedIcons()

ilLPStatusIconsTest::testSomeExamplesForRenderedIcons ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 162 of file ilLPStatusIconsTest.php.

162  : void
163  {
164  //try rendering some icons
165  $this->assertSame(
166  'rendered: path(' . $this->path .
167  '), alt(' . $this->alt .
168  '), size(' . $this->size . ')',
169  $instances['long']->renderIcon($this->path, $this->alt)
170  );
171 
172  $this->assertSame(
173  'rendered: path(' . $this->path .
174  '), alt(' . $this->alt .
175  '), size(' . $this->size . ')',
176  $instances['short']->renderIcon($this->path, $this->alt)
177  );
178  }

◆ testTripleton()

ilLPStatusIconsTest::testTripleton ( )
Returns
array<string, ilLPStatusIcons>

Definition at line 80 of file ilLPStatusIconsTest.php.

References $renderer, ilLPStatusIcons\getInstance(), getUIFactory(), getUIRenderer(), ilLPStatusIcons\ICON_VARIANT_LONG, ilLPStatusIcons\ICON_VARIANT_SCORM, and ilLPStatusIcons\ICON_VARIANT_SHORT.

80  : array
81  {
82  $factory = $this->getUIFactory();
83  $renderer = $this->getUIRenderer();
84 
87 
90 
93 
94  $this->assertSame($short1, $short2);
95  $this->assertSame($long1, $long2);
96  $this->assertSame($scorm1, $scorm2);
97 
98  $this->assertNotSame($long1, $short1);
99  $this->assertNotSame($long1, $scorm1);
100  $this->assertNotSame($short1, $scorm1);
101 
102  return ['long' => $long1, 'short' => $short1, 'scorm' => $scorm1];
103  }
$renderer
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
+ Here is the call graph for this function:

Field Documentation

◆ $alt

ilLPStatusIconsTest::$alt = 'alt'
protected

Definition at line 36 of file ilLPStatusIconsTest.php.

◆ $path

ilLPStatusIconsTest::$path = 'sample/path'
protected

Definition at line 35 of file ilLPStatusIconsTest.php.

◆ $size

ilLPStatusIconsTest::$size = Icon::SMALL
protected

Definition at line 37 of file ilLPStatusIconsTest.php.


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