diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index ed8c22b..85d91ee 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -40,4 +40,14 @@ jobs:
composer-options: --ignore-platform-reqs
- name: Run tests
- run: composer run phpunit -- --coverage-text
+ run: composer run phpunit -- --coverage-clover .phpunit.cache/clover.xml
+
+ - name: Upload coverage reports to Codecov
+ if: ${{ success() && matrix.php == '8.2' }}
+ uses: codecov/codecov-action@v3
+ env:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+ with:
+ files: ./.phpunit.cache/clover.xml
+ fail_ci_if_error: true
+ verbose: true
diff --git a/README.md b/README.md
index e200ed8..1325e1a 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
[](https://github.com/Art4/json-api-client/releases)
[](LICENSE)
[](https://github.com/Art4/json-api-client/actions)
+[](https://codecov.io/gh/Art4/json-api-client)
[](https://packagist.org/packages/art4/json-api-client)
JsonApiClient :construction_worker_woman: is a PHP Library to validate and handle the response body from a [JSON API](http://jsonapi.org) Server.
diff --git a/phpunit.xml b/phpunit.xml
index 03c0f13..002a138 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -19,12 +19,6 @@
tests/Functional/
tests/BC/
-
- tests/Unit/
-
-
- tests/Functional/
-
diff --git a/src/V1/Factory.php b/src/V1/Factory.php
index 8d99636..f1bab75 100644
--- a/src/V1/Factory.php
+++ b/src/V1/Factory.php
@@ -67,7 +67,11 @@ public function make($name, array $args = []): Accessable
$object = $class->newInstanceArgs($args);
if (! $object instanceof Accessable) {
- throw new FactoryException($this->classes[$name] . ' must be instance of `Art4\JsonApiClient\Accessable`');
+ throw new FactoryException(sprintf(
+ '%s must be instance of `%s`',
+ $this->classes[$name],
+ Accessable::class
+ ));
}
return $object;
diff --git a/tests/Unit/V1/FactoryTest.php b/tests/Unit/V1/FactoryTest.php
index a96aaef..5d1b6b0 100644
--- a/tests/Unit/V1/FactoryTest.php
+++ b/tests/Unit/V1/FactoryTest.php
@@ -13,6 +13,7 @@
use Art4\JsonApiClient\V1\Factory;
use Art4\JsonApiClient\V1\ResourceNull;
use PHPUnit\Framework\TestCase;
+use stdClass;
class FactoryTest extends TestCase
{
@@ -49,4 +50,18 @@ public function testMakeAnUndefindedClassThrowsException()
$class = $factory->make('NotExistent');
}
+
+ public function testMakeWithClassNotImplementingAccessableThrowsException()
+ {
+ $factory = new Factory([
+ 'Default' => stdClass::class,
+ ]);
+
+ $this->expectException(FactoryException::class);
+ $this->expectExceptionMessage(
+ 'stdClass must be instance of `Art4\JsonApiClient\Accessable`'
+ );
+
+ $class = $factory->make('Default');
+ }
}