Skip to content

Commit e9d9ea7

Browse files
committed
Clean
1 parent 15df6dd commit e9d9ea7

File tree

1 file changed

+6
-42
lines changed

1 file changed

+6
-42
lines changed

src/Icons/tests/Unit/IconifyTest.php

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Symfony\Component\HttpClient\Response\MockResponse;
1919
use Symfony\UX\Icons\Exception\IconNotFoundException;
2020
use Symfony\UX\Icons\Iconify;
21-
use Symfony\UX\Icons\Svg\Icon;
2221

2322
/**
2423
* @author Simon André <[email protected]>
@@ -53,13 +52,7 @@ public function testFetchIcon(): void
5352

5453
public function testFetchIconThrowsWhenIconSetDoesNotExists(): void
5554
{
56-
$iconify = new Iconify(
57-
cache: new NullAdapter(),
58-
endpoint: 'https://example.com',
59-
http: new MockHttpClient([
60-
new JsonMockResponse([]),
61-
]),
62-
);
55+
$iconify = new Iconify(new NullAdapter(), 'https://example.com', new MockHttpClient(new JsonMockResponse([])));
6356

6457
$this->expectException(IconNotFoundException::class);
6558
$this->expectExceptionMessage('The icon "bi:heart" does not exist on iconify.design.');
@@ -130,50 +123,21 @@ public function testGetMetadata(): void
130123
$this->assertSame('Font Awesome Solid', $metadata['name']);
131124
}
132125

133-
/**
134-
* @dataProvider provideHttpErrors
135-
*/
136-
public function testGetMetadataWhenHttpError(int $code, string $expectedException): void
137-
{
138-
$mockClient = $this->createHttpClient([], $code);
139-
$iconify = new Iconify(new NullAdapter(), 'https://localhost', $mockClient);
140-
141-
$this->expectException($expectedException);
142-
143-
$iconify->metadataFor('foo');
144-
}
145-
146126
public function testFetchSvg(): void
147127
{
148128
$responseFile = __DIR__.'/../Fixtures/Iconify/icon.svg';
149-
$client = new MockHttpClient(MockResponse::fromFile($responseFile));
129+
$client = new MockHttpClient([
130+
JsonMockResponse::fromFile(__DIR__.'/../Fixtures/Iconify/collections.json'),
131+
MockResponse::fromFile($responseFile),
132+
]);
150133
$iconify = new Iconify(new NullAdapter(), 'https://localhost', $client);
151134

152-
$svg = $iconify->fetchSvg('foo', 'bar');
135+
$svg = $iconify->fetchSvg('fa6-regular', 'bar');
153136

154137
$this->assertIsString($svg);
155138
$this->stringContains('-.224l.235-.468ZM6.013 2.06c-.649-.1', $svg);
156139
}
157140

158-
/**
159-
* @dataProvider provideHttpErrors
160-
*/
161-
public function testFetchSvgWhenHttpError(int $code, string $expectedException): void
162-
{
163-
$mockClient = $this->createHttpClient([], $code);
164-
$iconify = new Iconify(new NullAdapter(), 'https://localhost', $mockClient);
165-
166-
$this->expectException($expectedException);
167-
$iconify->fetchSvg('foo', 'bar');
168-
}
169-
170-
public static function provideHttpErrors(): iterable
171-
{
172-
yield [400, IconNotFoundException::class];
173-
yield [404, IconNotFoundException::class];
174-
yield [500, IconNotFoundException::class];
175-
}
176-
177141
private function createHttpClient(mixed $data, int $code = 200): MockHttpClient
178142
{
179143
$mockResponse = new JsonMockResponse($data, ['http_code' => $code]);

0 commit comments

Comments
 (0)