Test on avatar implementation.
More...
|
const | ICON_PATH = __DIR__ . "/../../../../../../../assets/images/" |
|
Test on avatar implementation.
Definition at line 30 of file AvatarTest.php.
◆ getAvatarFactory()
AvatarTest::getAvatarFactory |
( |
| ) |
|
|
private |
Definition at line 34 of file AvatarTest.php.
Referenced by testAbbreviation(), testAlternativeText(), testColorVariant(), testConstruction(), testCrc32(), testHTMLInCustomImage(), testHTMLInLabel(), testPicturePath(), testRenderingLetter(), testRenderingPicture(), testRenderingPictureWithSomeAlternativeText(), and testUsername().
36 return new I\Component\Symbol\Avatar\Factory();
◆ getRandom26StringsForAllColorVariants()
AvatarTest::getRandom26StringsForAllColorVariants |
( |
int |
$color_variants = 26 , |
|
|
int |
$length = 2 |
|
) |
| |
- Parameters
-
int | $color_variants | |
int | $length | |
- Returns
- Generator|Closure
Definition at line 199 of file AvatarTest.php.
Referenced by testCrc32().
201 $sh =
static function ($length = 10) {
203 str_shuffle(str_repeat(
204 $x =
'abcdefghijklmnopqrstuvwxyz',
205 (
int) ceil($length / strlen($x))
216 $probe = crc32($str);
217 $i = ($probe % $color_variants) + 1;
218 if (!in_array($i, $strings,
true)) {
222 if (count($strings) === $color_variants) {
◆ testAbbreviation()
AvatarTest::testAbbreviation |
( |
| ) |
|
Definition at line 51 of file AvatarTest.php.
References Vendor\Package\$f, and getAvatarFactory().
55 $this->assertEquals(
'ro',
$f->letter(
'ro')->getAbbreviation());
56 $this->assertEquals(
'ro',
$f->letter(
'root')->getAbbreviation());
57 $this->assertEquals(
'Ro',
$f->letter(
'Root')->getAbbreviation());
58 $this->assertEquals(
'RO',
$f->letter(
'ROOT')->getAbbreviation());
◆ testAlternativeText()
AvatarTest::testAlternativeText |
( |
| ) |
|
Definition at line 138 of file AvatarTest.php.
References Vendor\Package\$f, and getAvatarFactory().
141 $this->assertEquals(
"",
$f->picture(
'',
'ro')->getLabel());
142 $this->assertEquals(
"",
$f->letter(
'',
'ro')->getLabel());
143 $this->assertEquals(
"alternative",
$f->picture(
'',
'ro')
144 ->withLabel(
"alternative")
146 $this->assertEquals(
"alternative",
$f->letter(
'',
'ro')
147 ->withLabel(
"alternative")
◆ testColorVariant()
AvatarTest::testColorVariant |
( |
| ) |
|
◆ testConstruction()
AvatarTest::testConstruction |
( |
| ) |
|
Definition at line 39 of file AvatarTest.php.
References Vendor\Package\$f, and getAvatarFactory().
42 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Avatar\\Factory",
$f);
44 $le =
$f->letter(
'ru');
45 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Avatar\\Letter", $le);
47 $ci =
$f->picture(self::ICON_PATH .
'placeholder/no_photo_xsmall.jpg',
'ru');
48 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Symbol\\Avatar\\Picture", $ci);
◆ testCrc32()
AvatarTest::testCrc32 |
( |
| ) |
|
Definition at line 121 of file AvatarTest.php.
References Vendor\Package\$f, getAvatarFactory(), and getRandom26StringsForAllColorVariants().
125 $number_of_colors = 26;
128 $calculated_color_variant = (crc32($abb) % $number_of_colors) + 1;
129 $this->assertEquals($calculated_color_variant,
$f->letter($abb)->getBackgroundColorVariant());
134 $this->assertEquals($color,
$f->letter($variant)->getBackgroundColorVariant());
getRandom26StringsForAllColorVariants(int $color_variants=26, int $length=2)
◆ testHTMLInCustomImage()
AvatarTest::testHTMLInCustomImage |
( |
| ) |
|
Definition at line 242 of file AvatarTest.php.
References Vendor\Package\$f, $r, and getAvatarFactory().
245 $r = $this->getDefaultRenderer();
247 $avatar =
$f->picture(
'<h1>path</h1>',
'user');
248 $html = $this->brutallyTrimHTML(
$r->render($avatar));
249 $expected = $this->brutallyTrimHTML(
' 250 <span class="il-avatar il-avatar-picture il-avatar-size-large"> 251 <img src="<h1>path</h1>" alt="user_avatar"/> 253 $this->assertEquals($expected, $html);
◆ testHTMLInLabel()
AvatarTest::testHTMLInLabel |
( |
| ) |
|
Definition at line 228 of file AvatarTest.php.
References Vendor\Package\$f, $r, and getAvatarFactory().
231 $r = $this->getDefaultRenderer();
233 $avatar =
$f->letter(
'user')->withLabel(
'<h1>label</h1>');
234 $html = $this->brutallyTrimHTML(
$r->render($avatar));
235 $expected = $this->brutallyTrimHTML(
' 236 <span class="il-avatar il-avatar-letter il-avatar-size-large il-avatar-letter-color-11" aria-label="<h1>label</h1>" role="img"> 237 <span class="abbreviation">us</span> 239 $this->assertEquals($expected, $html);
◆ testPicturePath()
AvatarTest::testPicturePath |
( |
| ) |
|
◆ testRenderingLetter()
AvatarTest::testRenderingLetter |
( |
| ) |
|
Definition at line 151 of file AvatarTest.php.
References Vendor\Package\$f, $r, and getAvatarFactory().
154 $r = $this->getDefaultRenderer();
156 $letter =
$f->letter(
'ro');
157 $html = $this->brutallyTrimHTML(
$r->render($letter));
158 $expected = $this->brutallyTrimHTML(
' 159 <span class="il-avatar il-avatar-letter il-avatar-size-large il-avatar-letter-color-1" aria-label="user_avatar" role="img"> 160 <span class="abbreviation">ro</span> 162 $this->assertEquals($expected, $html);
◆ testRenderingPicture()
AvatarTest::testRenderingPicture |
( |
| ) |
|
Definition at line 165 of file AvatarTest.php.
References Vendor\Package\$f, $r, and getAvatarFactory().
168 $r = $this->getDefaultRenderer();
170 $str =
'/path/to/picture.jpg';
171 $letter =
$f->picture($str,
'ro');
172 $html = $this->brutallyTrimHTML(
$r->render($letter));
173 $expected = $this->brutallyTrimHTML(
' 174 <span class="il-avatar il-avatar-picture il-avatar-size-large"> 175 <img src="/path/to/picture.jpg" alt="user_avatar"/> 177 $this->assertEquals($expected, $html);
◆ testRenderingPictureWithSomeAlternativeText()
AvatarTest::testRenderingPictureWithSomeAlternativeText |
( |
| ) |
|
Definition at line 180 of file AvatarTest.php.
References Vendor\Package\$f, $r, and getAvatarFactory().
183 $r = $this->getDefaultRenderer();
185 $str =
'/path/to/picture.jpg';
186 $letter =
$f->picture($str,
'ro')->withLabel(
"alternative");
187 $html = $this->brutallyTrimHTML(
$r->render($letter));
188 $expected = $this->brutallyTrimHTML(
' 189 <span class="il-avatar il-avatar-picture il-avatar-size-large"> 190 <img src="/path/to/picture.jpg" alt="alternative"/> 192 $this->assertEquals($expected, $html);
◆ testUsername()
AvatarTest::testUsername |
( |
| ) |
|
Definition at line 61 of file AvatarTest.php.
References Vendor\Package\$f, and getAvatarFactory().
65 $this->assertEquals(
'ro',
$f->letter(
'ro')->getUsername());
66 $this->assertEquals(
'ro',
$f->picture(
'',
'ro')->getUsername());
67 $this->assertEquals(
'root',
$f->letter(
'root')->getUsername());
68 $this->assertEquals(
'root',
$f->picture(
'',
'root')->getUsername());
69 $this->assertEquals(
'Root',
$f->letter(
'Root')->getUsername());
70 $this->assertEquals(
'Root',
$f->picture(
'',
'Root')->getUsername());
71 $this->assertEquals(
'ROOT',
$f->letter(
'ROOT')->getUsername());
72 $this->assertEquals(
'ROOT',
$f->picture(
'',
'ROOT')->getUsername());
◆ ICON_PATH
const AvatarTest::ICON_PATH = __DIR__ . "/../../../../../../../assets/images/" |
|
protected |
The documentation for this class was generated from the following file: