Skip to content

Commit 10a5b59

Browse files
committed
Allow phpunit 8 and use pcov for coverage
1 parent 8b3e4ce commit 10a5b59

26 files changed

+72
-51
lines changed

.circleci/config.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ commands:
3939
command: |
4040
sudo pecl install mongodb-1.5.4
4141
sudo docker-php-ext-enable mongodb
42+
install-pcov-php-extension:
43+
steps:
44+
- run:
45+
name: Install pcov PHP extension
46+
command: |
47+
sudo pecl install pcov-1.0.6
48+
sudo docker-php-ext-enable pcov
4249
merge-code-coverage-reports:
4350
parameters:
4451
dir:
@@ -51,14 +58,16 @@ commands:
5158
- run:
5259
name: Download phpcov
5360
command: |
54-
if [ ! -e phpcov.phar ]; then
61+
if ! command -v phpcov; then
5562
wget https://phar.phpunit.de/phpcov.phar
63+
chmod +x phpcov.phar
64+
sudo mv phpcov.phar /usr/local/bin/phpcov
5665
fi
5766
- run:
5867
name: Merge code coverage reports
5968
command: |
6069
mkdir -p "$(dirname -- "<< parameters.out >>")"
61-
phpdbg -qrr phpcov.phar merge --clover "<< parameters.out >>" "<< parameters.dir >>"
70+
phpcov merge --clover "<< parameters.out >>" "<< parameters.dir >>"
6271
merge-test-reports:
6372
parameters:
6473
dir:
@@ -263,6 +272,7 @@ jobs:
263272
steps:
264273
- checkout
265274
- install-mongodb-php-extension
275+
- install-pcov-php-extension
266276
- disable-xdebug-php-extension
267277
- disable-php-memory-limit
268278
- update-composer
@@ -276,7 +286,7 @@ jobs:
276286
mkdir -p build/logs/phpunit build/coverage
277287
split_tests=$(find tests -name '*Test.php' | circleci tests split --split-by=timings)
278288
export PARALLEL='-j10% --joblog build/logs/parallel.log --rpl {_}\ s/\\//_/g;'
279-
phpunit_cmd='phpdbg -qrr vendor/bin/phpunit --coverage-php build/coverage/coverage-{_}.cov --log-junit build/logs/phpunit/{_}.xml --exclude-group mongodb,resource-hog --colors=always {}'
289+
phpunit_cmd='vendor/bin/phpunit --coverage-php build/coverage/coverage-{_}.cov --log-junit build/logs/phpunit/{_}.xml --exclude-group mongodb,resource-hog --colors=always {}'
280290
echo "$split_tests" | parallel "$phpunit_cmd" || echo "$split_tests" | parallel --retry-failed "$phpunit_cmd"
281291
- restore-npm-cache
282292
- merge-test-reports:
@@ -310,6 +320,7 @@ jobs:
310320
steps:
311321
- checkout
312322
- install-mongodb-php-extension
323+
- install-pcov-php-extension
313324
- disable-xdebug-php-extension
314325
- disable-php-memory-limit
315326
- update-composer
@@ -323,7 +334,7 @@ jobs:
323334
mkdir -p build/logs/behat build/coverage
324335
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature' -not -path 'features/elasticsearch/*' -not -path 'features/mongodb/*' | circleci tests split --split-by=timings); do
325336
_f=$(echo "$f" | tr / _)
326-
FEATURE="${_f}" phpdbg -qrr vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat/"${_f}" --profile=default-coverage --no-interaction "$f"
337+
FEATURE="${_f}" vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat/"${_f}" --profile=default-coverage --no-interaction "$f"
327338
done
328339
- restore-npm-cache
329340
- merge-test-reports:
@@ -355,6 +366,7 @@ jobs:
355366
steps:
356367
- checkout
357368
- install-mongodb-php-extension
369+
- install-pcov-php-extension
358370
- disable-xdebug-php-extension
359371
- disable-php-memory-limit
360372
- update-composer
@@ -367,7 +379,7 @@ jobs:
367379
name: Run PHPUnit tests
368380
command: |
369381
mkdir -p build/logs/phpunit
370-
phpdbg -qrr vendor/bin/phpunit --coverage-clover build/logs/clover.xml --log-junit build/logs/phpunit/junit.xml --exclude-group resource-hog --colors=always --configuration phpunit_mongodb.xml
382+
vendor/bin/phpunit --coverage-clover build/logs/clover.xml --log-junit build/logs/phpunit/junit.xml --exclude-group resource-hog --colors=always --configuration phpunit_mongodb.xml
371383
- store_test_results:
372384
path: build/logs
373385
- store_artifacts:
@@ -392,6 +404,7 @@ jobs:
392404
steps:
393405
- checkout
394406
- install-mongodb-php-extension
407+
- install-pcov-php-extension
395408
- disable-xdebug-php-extension
396409
- disable-php-memory-limit
397410
- update-composer
@@ -404,7 +417,7 @@ jobs:
404417
name: Run Behat tests
405418
command: |
406419
mkdir -p build/logs/behat
407-
phpdbg -qrr vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat --profile=mongodb-coverage --no-interaction
420+
vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat --profile=mongodb-coverage --no-interaction
408421
- restore-npm-cache
409422
- merge-test-reports:
410423
dir: build/logs/behat
@@ -435,6 +448,7 @@ jobs:
435448
steps:
436449
- checkout
437450
- install-mongodb-php-extension
451+
- install-pcov-php-extension
438452
- disable-xdebug-php-extension
439453
- disable-php-memory-limit
440454
- update-composer
@@ -447,7 +461,7 @@ jobs:
447461
name: Run Behat tests
448462
command: |
449463
mkdir -p build/logs/behat
450-
phpdbg -qrr vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat --profile=elasticsearch-coverage --no-interaction
464+
vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat --profile=elasticsearch-coverage --no-interaction
451465
- restore-npm-cache
452466
- merge-test-reports:
453467
dir: build/logs/behat

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.php_cs
22
/.php_cs.cache
3+
/.phpunit.result.cache
34
/build/
45
/composer.lock
56
/composer.phar

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"phpstan/phpstan-doctrine": "^0.11",
5454
"phpstan/phpstan-phpunit": "^0.11",
5555
"phpstan/phpstan-symfony": "^0.11",
56-
"phpunit/phpunit": "^7.5.2",
56+
"phpunit/phpunit": "^7.5.2 || ^8.0",
5757
"psr/log": "^1.0",
5858
"ramsey/uuid": "^3.7",
5959
"ramsey/uuid-doctrine": "^1.4",

src/Test/DoctrineMongoDbOdmFilterTestCase.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2222

2323
/**
24+
* @internal
25+
*
2426
* @author Alan Poulain <[email protected]>
2527
*/
2628
abstract class DoctrineMongoDbOdmFilterTestCase extends KernelTestCase
@@ -45,7 +47,7 @@ abstract class DoctrineMongoDbOdmFilterTestCase extends KernelTestCase
4547
*/
4648
protected $filterClass;
4749

48-
protected function setUp()
50+
protected function setUp(): void
4951
{
5052
self::bootKernel();
5153

src/Test/DoctrineMongoDbOdmSetup.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
/**
2323
* Convenience class for setting up Doctrine from different installations and configurations.
2424
*
25+
* @internal
26+
*
2527
* @author Benjamin Eberlei <[email protected]>
2628
* @author Alan Poulain <[email protected]>
2729
*/

src/Test/DoctrineOrmFilterTestCase.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
use Symfony\Component\HttpFoundation\RequestStack;
2525

2626
/**
27+
* @internal
28+
*
2729
* @author Kévin Dunglas <[email protected]>
2830
*/
2931
abstract class DoctrineOrmFilterTestCase extends KernelTestCase
@@ -53,7 +55,7 @@ abstract class DoctrineOrmFilterTestCase extends KernelTestCase
5355
*/
5456
protected $filterClass;
5557

56-
protected function setUp()
58+
protected function setUp(): void
5759
{
5860
self::bootKernel();
5961

tests/Bridge/Doctrine/MongoDbOdm/Extension/PaginationExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PaginationExtensionTest extends TestCase
4343
{
4444
private $managerRegistryProphecy;
4545

46-
protected function setUp()
46+
protected function setUp(): void
4747
{
4848
parent::setUp();
4949

tests/Bridge/Elasticsearch/DataProvider/PaginatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function (array $document): Foo {
147147
);
148148
}
149149

150-
protected function setUp()
150+
protected function setUp(): void
151151
{
152152
$this->paginator = $this->getPaginator(4, 4);
153153
}

tests/Bridge/Symfony/Bundle/Command/SwaggerCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SwaggerCommandTest extends KernelTestCase
3030
*/
3131
private $tester;
3232

33-
protected function setUp()
33+
protected function setUp(): void
3434
{
3535
self::bootKernel();
3636

@@ -70,7 +70,7 @@ public function testExecuteWithYamlVersion3()
7070
operationId: getDummyCarCollection
7171
YAML;
7272

73-
$this->assertContains($expected, $result, 'nested object should be present.');
73+
$this->assertStringContainsString($expected, $result, 'nested object should be present.');
7474

7575
$expected = <<<YAML
7676
'/dummy_cars/{id}':
@@ -79,8 +79,8 @@ public function testExecuteWithYamlVersion3()
7979
operationId: getDummyCarItem
8080
YAML;
8181

82-
$this->assertContains($expected, $result, 'arrays should be correctly formatted.');
83-
$this->assertContains('openapi: 3.0.2', $result);
82+
$this->assertStringContainsString($expected, $result, 'arrays should be correctly formatted.');
83+
$this->assertStringContainsString('openapi: 3.0.2', $result);
8484

8585
$expected = <<<YAML
8686
info:
@@ -90,7 +90,7 @@ public function testExecuteWithYamlVersion3()
9090
This is a test API.
9191
Made with love
9292
YAML;
93-
$this->assertContains($expected, $result, 'multiline formatting must be preserved (using literal style).');
93+
$this->assertStringContainsString($expected, $result, 'multiline formatting must be preserved (using literal style).');
9494
}
9595

9696
public function testExecuteOpenApiVersion2WithYaml()
@@ -99,7 +99,7 @@ public function testExecuteOpenApiVersion2WithYaml()
9999

100100
$result = $this->tester->getDisplay();
101101
$this->assertYaml($result);
102-
$this->assertContains("swagger: '2.0'", $result);
102+
$this->assertStringContainsString("swagger: '2.0'", $result);
103103
}
104104

105105
public function testExecuteWithBadArguments()

tests/Bridge/Symfony/Bundle/DataCollector/RequestDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class RequestDataCollectorTest extends TestCase
4747
private $metadataFactory;
4848
private $filterLocator;
4949

50-
protected function setUp()
50+
protected function setUp(): void
5151
{
5252
$this->response = $this->createMock(Response::class);
5353
$this->attributes = $this->prophesize(ParameterBag::class);

0 commit comments

Comments
 (0)