Skip to content

Commit 08bed29

Browse files
committed
Reach 100% code coverage
1 parent 4134936 commit 08bed29

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

phpunit.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
<directory suffix="Test.php">tests/Functional/</directory>
2020
<directory suffix="Test.php">tests/BC/</directory>
2121
</testsuite>
22-
<testsuite name="unit">
23-
<directory suffix="Test.php">tests/Unit/</directory>
24-
</testsuite>
25-
<testsuite name="functional">
26-
<directory suffix="Test.php">tests/Functional/</directory>
27-
</testsuite>
2822
</testsuites>
2923
<source>
3024
<include>

src/V1/Factory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ public function make($name, array $args = []): Accessable
6767
$object = $class->newInstanceArgs($args);
6868

6969
if (! $object instanceof Accessable) {
70-
throw new FactoryException($this->classes[$name] . ' must be instance of `Art4\JsonApiClient\Accessable`');
70+
throw new FactoryException(sprintf(
71+
'%s must be instance of `%s`',
72+
$this->classes[$name],
73+
Accessable::class
74+
));
7175
}
7276

7377
return $object;

tests/Unit/V1/FactoryTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Art4\JsonApiClient\V1\Factory;
1414
use Art4\JsonApiClient\V1\ResourceNull;
1515
use PHPUnit\Framework\TestCase;
16+
use stdClass;
1617

1718
class FactoryTest extends TestCase
1819
{
@@ -49,4 +50,18 @@ public function testMakeAnUndefindedClassThrowsException()
4950

5051
$class = $factory->make('NotExistent');
5152
}
53+
54+
public function testMakeWithClassNotImplementingAccessableThrowsException()
55+
{
56+
$factory = new Factory([
57+
'Default' => stdClass::class,
58+
]);
59+
60+
$this->expectException(FactoryException::class);
61+
$this->expectExceptionMessage(
62+
'stdClass must be instance of `Art4\JsonApiClient\Accessable`'
63+
);
64+
65+
$class = $factory->make('Default');
66+
}
5267
}

0 commit comments

Comments
 (0)