diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 60c4c45..dee7ace 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -27,6 +27,10 @@ jobs: php: '7.4' - laravel: '9.*' php: '7.4' + - laravel: '9.*' + dependency-version: 'prefer-lowest' + - laravel: '8.*' + dependency-version: 'prefer-lowest' name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/composer.json b/composer.json index 93e0203..d0e8e8b 100644 --- a/composer.json +++ b/composer.json @@ -33,8 +33,9 @@ }, "require-dev": { "gajus/dindent": "^2.0", + "laravel/pint": "^1.16", "orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0", - "phpunit/phpunit": "^9.3 || ^10" + "phpunit/phpunit": "^9.3 || ^10.0" }, "autoload": { "psr-4": { @@ -57,6 +58,7 @@ } }, "scripts": { + "fix": "@php vendor/bin/pint", "test": "vendor/bin/phpunit", "test-coverage": "vendor/bin/phpunit --coverage-html coverage" } diff --git a/src/Unavatar.php b/src/Unavatar.php index 41ccbcf..3c1ef5d 100644 --- a/src/Unavatar.php +++ b/src/Unavatar.php @@ -14,7 +14,7 @@ use JsonSerializable; use Symfony\Component\HttpFoundation\Response; -class Unavatar extends BaseUnavatar implements Renderable, Responsable, Htmlable, Jsonable, JsonSerializable, Arrayable +class Unavatar extends BaseUnavatar implements Arrayable, Htmlable, Jsonable, JsonSerializable, Renderable, Responsable { public static function make(string $identifier, ?string $provider = null): self { diff --git a/src/View/Components/Img.php b/src/View/Components/Img.php index cf2a296..6aa69f4 100644 --- a/src/View/Components/Img.php +++ b/src/View/Components/Img.php @@ -10,7 +10,9 @@ class Img extends Component { public string $identifier; + protected ?string $provider = null; + protected ?string $fallback = null; public function __construct( diff --git a/tests/UnavatarTest.php b/tests/UnavatarTest.php index df88d3c..340f85b 100644 --- a/tests/UnavatarTest.php +++ b/tests/UnavatarTest.php @@ -19,8 +19,8 @@ public function it_is_renderable(): void { $unavatar = Unavatar::github('Gummibeer'); - static::assertArrayHasKey(Renderable::class, class_implements($unavatar)); - static::assertSame('Gummibeer's github avatar', $unavatar->render()); + self::assertArrayHasKey(Renderable::class, class_implements($unavatar)); + self::assertSame(''.htmlspecialchars('Gummibeer\'s github avatar').'', $unavatar->render()); } /** @test */ @@ -28,8 +28,8 @@ public function it_is_htmlable(): void { $unavatar = Unavatar::github('Gummibeer'); - static::assertArrayHasKey(Htmlable::class, class_implements($unavatar)); - static::assertSame('Gummibeer's github avatar', $unavatar->toHtml()); + self::assertArrayHasKey(Htmlable::class, class_implements($unavatar)); + self::assertSame(''.htmlspecialchars('Gummibeer\'s github avatar').'', $unavatar->toHtml()); } /** @test */ @@ -37,12 +37,12 @@ public function it_is_responsable_redirect(): void { $unavatar = Unavatar::github('Gummibeer'); - static::assertArrayHasKey(Responsable::class, class_implements($unavatar)); + self::assertArrayHasKey(Responsable::class, class_implements($unavatar)); $redirect = $unavatar->toResponse(Request::createFromGlobals()); - static::assertInstanceOf(RedirectResponse::class, $redirect); - static::assertSame('https://unavatar.io/github/Gummibeer', $redirect->getTargetUrl()); + self::assertInstanceOf(RedirectResponse::class, $redirect); + self::assertSame('https://unavatar.io/github/Gummibeer', $redirect->getTargetUrl()); } /** @test */ @@ -50,16 +50,16 @@ public function it_is_responsable_json(): void { $unavatar = Unavatar::github('Gummibeer'); - static::assertArrayHasKey(Responsable::class, class_implements($unavatar)); + self::assertArrayHasKey(Responsable::class, class_implements($unavatar)); $request = Request::createFromGlobals(); $request->headers->set('X-Requested-With', 'XMLHttpRequest'); $response = $unavatar->toResponse($request); - static::assertInstanceOf(JsonResponse::class, $response); + self::assertInstanceOf(JsonResponse::class, $response); $data = $response->getData(true); - static::assertIsArray($data); - static::assertArrayHasKey('url', $data); + self::assertIsArray($data); + self::assertArrayHasKey('url', $data); } /** @test */ @@ -67,13 +67,13 @@ public function it_is_jsonable(): void { $unavatar = Unavatar::github('Gummibeer'); - static::assertArrayHasKey(Jsonable::class, class_implements($unavatar)); + self::assertArrayHasKey(Jsonable::class, class_implements($unavatar)); $data = $unavatar->toJson(); - static::assertJson($data); + self::assertJson($data); $data = json_decode($data, true); - static::assertIsArray($data); - static::assertArrayHasKey('url', $data); + self::assertIsArray($data); + self::assertArrayHasKey('url', $data); } /** @test */ @@ -81,11 +81,11 @@ public function it_is_arrayable(): void { $unavatar = Unavatar::github('Gummibeer'); - static::assertArrayHasKey(Arrayable::class, class_implements($unavatar)); + self::assertArrayHasKey(Arrayable::class, class_implements($unavatar)); $data = $unavatar->toArray(); - static::assertIsArray($data); - static::assertArrayHasKey('url', $data); + self::assertIsArray($data); + self::assertArrayHasKey('url', $data); } /** @test */ @@ -93,10 +93,10 @@ public function it_is_arrayable_with_fallback(): void { $unavatar = Unavatar::github('Gummibeer')->fallback('https://example.com/avatar.jpg'); - static::assertArrayHasKey(Arrayable::class, class_implements($unavatar)); + self::assertArrayHasKey(Arrayable::class, class_implements($unavatar)); $data = $unavatar->toArray(); - static::assertIsArray($data); - static::assertArrayHasKey('url', $data); + self::assertIsArray($data); + self::assertArrayHasKey('url', $data); } }