ILIAS  release_8 Revision v8.19
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 32 of file ilLPStatusIconsTest.php.

Member Function Documentation

◆ testGetInstanceForInvalidVariant()

ilLPStatusIconsTest::testGetInstanceForInvalidVariant ( )

Definition at line 90 of file ilLPStatusIconsTest.php.

References $factory, and ilLPStatusIcons\getInstance().

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

◆ testImagePathAssetForLongVariant()

ilLPStatusIconsTest::testImagePathAssetForLongVariant ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 137 of file ilLPStatusIconsTest.php.

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

◆ testImagePathRunningForLongVariant()

ilLPStatusIconsTest::testImagePathRunningForLongVariant ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 127 of file ilLPStatusIconsTest.php.

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

◆ testRenderScormIcons()

ilLPStatusIconsTest::testRenderScormIcons ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 169 of file ilLPStatusIconsTest.php.

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

◆ testSomeExamplesForImagePathsByStatus()

ilLPStatusIconsTest::testSomeExamplesForImagePathsByStatus ( array  $instances)

testTripleton

Parameters
array<string,ilLPStatusIcons>$instances

Definition at line 108 of file ilLPStatusIconsTest.php.

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

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

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

◆ testTripleton()

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

Definition at line 41 of file ilLPStatusIconsTest.php.

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

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

Field Documentation

◆ $alt

ilLPStatusIconsTest::$alt = 'alt'
protected

Definition at line 35 of file ilLPStatusIconsTest.php.

◆ $path

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

Definition at line 34 of file ilLPStatusIconsTest.php.

◆ $size

ilLPStatusIconsTest::$size = Icon::SMALL
protected

Definition at line 36 of file ilLPStatusIconsTest.php.


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