ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables 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 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 30 of file ilLPStatusIconsTest.php.

Member Function Documentation

◆ testGetInstanceForInvalidVariant()

ilLPStatusIconsTest::testGetInstanceForInvalidVariant ( )

Definition at line 88 of file ilLPStatusIconsTest.php.

References $factory, and ilLPStatusIcons\getInstance().

88  : void
89  {
90  $renderer = $this->getMockBuilder(Renderer::class)
91  ->disableOriginalConstructor()
92  ->getMock();
93 
94  $factory = $this->getMockBuilder(Factory::class)
95  ->disableOriginalConstructor()
96  ->getMock();
97 
98  $this->expectException(ilLPException::class);
99  ilLPStatusIcons::getInstance(793, $renderer, $factory);
100  }
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
$factory
Definition: metadata.php:58
+ Here is the call graph for this function:

◆ testImagePathAssetForLongVariant()

ilLPStatusIconsTest::testImagePathAssetForLongVariant ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 135 of file ilLPStatusIconsTest.php.

135  : void
136  {
137  $this->expectException(ilLPException::class);
138  $instances['long']->getImagePathAsset();
139  }

◆ testImagePathRunningForLongVariant()

ilLPStatusIconsTest::testImagePathRunningForLongVariant ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 125 of file ilLPStatusIconsTest.php.

125  : void
126  {
127  $this->expectException(ilLPException::class);
128  $instances['long']->getImagePathRunning();
129  }

◆ testRenderScormIcons()

ilLPStatusIconsTest::testRenderScormIcons ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 167 of file ilLPStatusIconsTest.php.

167  : void
168  {
169  $this->expectException(ilLPException::class);
170  $instances['scorm']->renderIcon('path', 'alt');
171  }

◆ testSomeExamplesForImagePathsByStatus()

ilLPStatusIconsTest::testSomeExamplesForImagePathsByStatus ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 106 of file ilLPStatusIconsTest.php.

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

106  : void
107  {
108  $path1 = $instances['long']->getImagePathInProgress();
109  $path2 = $instances['long']->getImagePathForStatus(ilLPStatus::LP_STATUS_IN_PROGRESS_NUM);
110  $this->assertSame($path1, $path2);
111 
112  $path1 = $instances['short']->getImagePathCompleted();
113  $path2 = $instances['short']->getImagePathForStatus(ilLPStatus::LP_STATUS_COMPLETED_NUM);
114  $this->assertSame($path1, $path2);
115 
116  $path1 = $instances['scorm']->getImagePathFailed();
117  $path2 = $instances['scorm']->getImagePathForStatus(ilLPStatus::LP_STATUS_FAILED_NUM);
118  $this->assertSame($path1, $path2);
119  }
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 145 of file ilLPStatusIconsTest.php.

145  : void
146  {
147  //try rendering some icons
148  $this->assertSame(
149  'rendered: path(' . $this->path .
150  '), alt(' . $this->alt .
151  '), size(' . $this->size . ')',
152  $instances['long']->renderIcon($this->path, $this->alt)
153  );
154 
155  $this->assertSame(
156  'rendered: path(' . $this->path .
157  '), alt(' . $this->alt .
158  '), size(' . $this->size . ')',
159  $instances['short']->renderIcon($this->path, $this->alt)
160  );
161  }

◆ testTripleton()

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

Definition at line 39 of file ilLPStatusIconsTest.php.

References $factory, ilLPStatusIcons\getInstance(), ilLPStatusIcons\ICON_VARIANT_LONG, ilLPStatusIcons\ICON_VARIANT_SCORM, and ilLPStatusIcons\ICON_VARIANT_SHORT.

39  : array
40  {
41  $utilMock = Mockery::mock('alias:' . ilUtil::class);
42  $utilMock->shouldReceive('getImagePath')
43  ->with(Mockery::type('string'))
44  ->andReturnUsing(function ($arg) {
45  return 'test/' . $arg;
46  });
47 
48  $renderer = Mockery::mock(Renderer::class);
49  $renderer->shouldReceive('render')
50  ->andReturnUsing(function ($arg1) {
51  return 'rendered: path(' . $arg1->getIconPath() .
52  '), alt(' . $arg1->getLabel() .
53  '), size(' . $arg1->getSize() . ')';
54  });
55 
56  $custom_icon = Mockery::mock(Custom::class);
57  $custom_icon->shouldReceive('getIconPath')
58  ->andReturn($this->path);
59  $custom_icon->shouldReceive('getSize')
60  ->andReturn($this->size);
61  $custom_icon->shouldReceive('getLabel')
62  ->andReturn($this->alt);
63 
64  $factory = Mockery::mock(Factory::class);
65  $factory->shouldReceive('symbol->icon->custom')
66  ->andReturn($custom_icon);
67 
70 
73 
76 
77  $this->assertSame($short1, $short2);
78  $this->assertSame($long1, $long2);
79  $this->assertSame($scorm1, $scorm2);
80 
81  $this->assertNotSame($long1, $short1);
82  $this->assertNotSame($long1, $scorm1);
83  $this->assertNotSame($short1, $scorm1);
84 
85  return ['long' => $long1, 'short' => $short1, 'scorm' => $scorm1];
86  }
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
$factory
Definition: metadata.php:58
+ Here is the call graph for this function:

Field Documentation

◆ $alt

ilLPStatusIconsTest::$alt = 'alt'
protected

Definition at line 33 of file ilLPStatusIconsTest.php.

◆ $path

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

Definition at line 32 of file ilLPStatusIconsTest.php.

◆ $size

ilLPStatusIconsTest::$size = Icon::SMALL
protected

Definition at line 34 of file ilLPStatusIconsTest.php.


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