Skip to content

Commit

Permalink
Merge pull request #10 from robertvanlienden/feature/testing-coverage
Browse files Browse the repository at this point in the history
Feature/testing coverage
  • Loading branch information
robertvanlienden authored Dec 30, 2024
2 parents 00a2f5c + 171b36f commit a423b23
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 11 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ jobs:
run: |
docker run --rm php-ci vendor/bin/phpstan --configuration=./development/tooling/phpstan.neon
- name: Run unit tests
- name: Run unit tests with coverage
run: |
docker run --rm php-ci vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox tests
docker run --rm -v $GITHUB_WORKSPACE:/workspace php-ci vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox tests --coverage-clover=/workspace/coverage.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: robertvanlienden/useragreementsbundle
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit.result.cache
.phpunit.*cache
coverage
vendor
composer.lock
6 changes: 5 additions & 1 deletion Taskfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ function task:phpstan { ## Run PHPStan
}

function task:tests { ## Run unit tests
dockercompose-exec vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox tests
dockercompose-exec vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox
}

function task:tests-with-coverage { ## Run unit tests with codestyle reports
dockercompose-exec vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox --coverage-html coverage
}

# =========================================================
Expand Down
7 changes: 7 additions & 0 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ RUN apk add --no-cache \

WORKDIR /www

RUN apk add linux-headers --no-cache $PHPIZE_DEPS --virtual .build-deps; \
pecl install xdebug; \
docker-php-ext-enable xdebug; \
apk del .build-deps;

RUN echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/xdebug.ini;

RUN set -eux; \
COMPOSER_MEMORY_LIMIT=2G composer install --prefer-dist --no-scripts --no-progress; \
composer clear-cache
Expand Down
30 changes: 23 additions & 7 deletions development/tooling/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="../../vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
shortenArraysForExportThreshold="10"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
displayDetailsOnPhpunitDeprecations="true"
failOnPhpunitDeprecation="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>./../../tests</directory>
</testsuite>
</testsuites>

<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>./../../src</directory>
</include>
</source>
</phpunit>
2 changes: 2 additions & 0 deletions tests/unit/AgreementServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace RobertvanLienden\UserAgreements\Tests\Service;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use RobertvanLienden\UserAgreements\Service\AgreementService;
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;

#[CoversClass(AgreementService::class)]
class AgreementServiceTest extends TestCase
{
private AgreementService $agreementService;
Expand Down

0 comments on commit a423b23

Please sign in to comment.