Skip to content

Commit 7009a92

Browse files
committed
Add missing test for ProjectFactory and raise coverage limit
1 parent f71ea29 commit 7009a92

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: Upload to Scrutinizer
6868
run: tools/ocular code-coverage:upload --format=php-clover build/logs/clover.xml
6969
- name: Quick check code coverage level
70-
run: php tests/coverage-checker.php 86
70+
run: php tests/coverage-checker.php 94
7171

7272
phpunit:
7373
runs-on: ${{ matrix.operating-system }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ psalm:
2626
.PHONY: test
2727
test:
2828
docker run -it --rm -v${CURDIR}:/github/workspace phpdoc/phpunit-ga
29-
docker run -it --rm -v${CURDIR}:/data -w /data php:7.2 -f ./tests/coverage-checker.php 86
29+
docker run -it --rm -v${CURDIR}:/data -w /data php:7.2 -f ./tests/coverage-checker.php 94
3030

3131
.PHONY: pre-commit-test
3232
pre-commit-test: test phpcs phpstan

tests/unit/phpDocumentor/Reflection/Php/ProjectFactoryTest.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Mockery\Adapter\Phpunit\MockeryTestCase;
1818
use phpDocumentor\Reflection\Exception;
1919
use phpDocumentor\Reflection\Fqsen;
20-
use phpDocumentor\Reflection\Php\Factory\DummyFactoryStrategy;
2120
use function array_keys;
2221
use function count;
2322
use function current;
@@ -43,12 +42,33 @@
4342
final class ProjectFactoryTest extends MockeryTestCase
4443
{
4544
/**
46-
* @covers ::__construct
45+
* Tests whether a factory can be instantiated using recommended factories.
46+
*
47+
* This test is unable to test which exact factories are instantiated because that is not exposed by
48+
* the factory. Even using assertEquals to do a regression test against a pre-populated factory does not
49+
* work because there is a piece of randomness inside one of the properties; causing the tests to fail when
50+
* you try to do it like that.
51+
*
52+
* @uses \phpDocumentor\Reflection\Middleware\ChainFactory
53+
* @uses \phpDocumentor\Reflection\Php\Factory\Property
54+
* @uses \phpDocumentor\Reflection\Php\Factory\Argument
55+
* @uses \phpDocumentor\Reflection\Php\Factory\Method
56+
* @uses \phpDocumentor\Reflection\Php\Factory\Class_
57+
* @uses \phpDocumentor\Reflection\Php\Factory\Interface_
58+
* @uses \phpDocumentor\Reflection\Php\Factory\ClassConstant
59+
* @uses \phpDocumentor\Reflection\Php\Factory\Define
60+
* @uses \phpDocumentor\Reflection\Php\Factory\GlobalConstant
61+
* @uses \phpDocumentor\Reflection\Php\Factory\Argument
62+
* @uses \phpDocumentor\Reflection\Php\Factory\Trait_
63+
* @uses \phpDocumentor\Reflection\Php\Factory\DocBlock
64+
* @uses \phpDocumentor\Reflection\Php\Factory\File
65+
* @uses \phpDocumentor\Reflection\Php\NodesFactory
66+
*
67+
* @covers ::createInstance
4768
*/
48-
public function testStrategiesAreChecked() : void
69+
public function testCreatingAnInstanceInstantiatesItWithTheRecommendedStrategies()
4970
{
50-
new ProjectFactory([new DummyFactoryStrategy()]);
51-
$this->assertTrue(true);
71+
$this->assertInstanceOf(ProjectFactory::class, ProjectFactory::createInstance());
5272
}
5373

5474
/**

0 commit comments

Comments
 (0)