Skip to content

Commit 0339149

Browse files
committed
add iconify tests
1 parent d0b2165 commit 0339149

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\UX\Icons\Tests\Unit\Registry;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Cache\Adapter\NullAdapter;
16+
use Symfony\Component\HttpClient\MockHttpClient;
17+
use Symfony\Component\HttpClient\Response\JsonMockResponse;
18+
use Symfony\UX\Icons\Icon;
19+
use Symfony\UX\Icons\Iconify;
20+
use Symfony\UX\Icons\Registry\IconifyOnDemandRegistry;
21+
22+
/**
23+
* @author Simon André <smn.andre@gmail.com>
24+
*/
25+
final class IconifyOnDemandRegistryTest extends TestCase
26+
{
27+
public function testWithIconSetAlias(): void
28+
{
29+
$client = new MockHttpClient([
30+
new JsonMockResponse(['lucide' => []]),
31+
new JsonMockResponse([
32+
'icons' => [
33+
'circle' => [
34+
'body' => '<path aria-label="lucide:circle"/>',
35+
'height' => 24,
36+
],
37+
],
38+
]),
39+
]);
40+
41+
$registry = new IconifyOnDemandRegistry(
42+
new Iconify(new NullAdapter(), 'https://example.com', $client),
43+
['bi' => 'lucide'],
44+
);
45+
46+
$icon = $registry->get('bi:circle');
47+
$this->assertInstanceOf(Icon::class, $icon);
48+
$this->assertSame('<path aria-label="lucide:circle"/>', $icon->getInnerSvg());
49+
}
50+
}

0 commit comments

Comments
 (0)