diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index 79968ea..8e5e751 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -64,16 +64,12 @@ jobs:
restore-keys: |
all-tools-${{ github.sha }}-
all-tools-
- - name: Setup PHP
- uses: shivammathur/setup-php@master
- with:
- php-version: 7.2
- extension-csv: mbstring, intl, iconv, libxml, dom, json, simplexml, zlib
- ini-values-csv: memory_limit=2G, display_errors=On, error_reporting=-1
- coverage: xdebug
- pecl: false
- - name: Run PHPUnit
- run: php tools/phpunit
+ - name: PHPUnit
+ uses: docker://phpdoc/phpunit-ga:latest
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - name: Quick check code coverage level
+ run: php tests/coverage-checker.php 89
phpunit:
runs-on: ${{ matrix.operating-system }}
diff --git a/.gitignore b/.gitignore
index 4a0e435..62394e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ vendor/
# By default the phpunit.xml.dist is provided; you can override this using a local config file
phpunit.xml
+.phpunit.result.cache
diff --git a/Makefile b/Makefile
index bdeae3d..a7bd91d 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,8 @@ psalm:
.PHONY: test
test:
- docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4-pcov tools/phpunit
+ docker run -it --rm -v${CURDIR}:/github/workspace phpdoc/phpunit-ga
+ docker run -it --rm -v${CURDIR}:/data -w /data php:7.2 -f ./tests/coverage-checker.php 89
.PHONY: pre-commit-test
pre-commit-test: test phpcs phpstan psalm
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 81f914c..b14e136 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -8,30 +8,31 @@
forceCoversAnnotation="true"
verbose="true"
bootstrap="vendor/autoload.php"
- >
-
-
- ./tests/unit
-
-
- ./tests/integration
-
-
-
-
- ./src/
-
-
-
-
-
-
-
-
+>
+
+
+ ./tests/unit
+
+
+ ./tests/integration
+
+
+
+
+ ./src/
+
+
+
+
+
+
+
+
+
diff --git a/src/DocBlock/Description.php b/src/DocBlock/Description.php
index 7d8e881..7b11b80 100644
--- a/src/DocBlock/Description.php
+++ b/src/DocBlock/Description.php
@@ -67,12 +67,11 @@ class Description
$this->bodyTemplate = $bodyTemplate;
$this->tags = $tags;
}
-
+
/**
- * Returns the body template
- * @return string
+ * Returns the body template.
*/
- public function getBodyTemplate(): string
+ public function getBodyTemplate() : string
{
return $this->bodyTemplate;
}
diff --git a/tests/coverage-checker.php b/tests/coverage-checker.php
new file mode 100755
index 0000000..5ba8bf7
--- /dev/null
+++ b/tests/coverage-checker.php
@@ -0,0 +1,31 @@
+xpath('//metrics');
+$totalElements = 0;
+$checkedElements = 0;
+
+foreach ($metrics as $metric) {
+ $totalElements += (int) $metric['elements'];
+ $checkedElements += (int) $metric['coveredelements'];
+}
+
+$coverage = ($checkedElements / $totalElements) * 100;
+
+if ($coverage < $percentage) {
+ echo 'Code coverage is ' . $coverage . '%, which is below the accepted ' . $percentage . '%' . PHP_EOL;
+ exit(1);
+}
+
+echo 'Code coverage is ' . $coverage . '% - OK!' . PHP_EOL;
diff --git a/tests/unit/DocBlock/DescriptionTest.php b/tests/unit/DocBlock/DescriptionTest.php
index 1cb3481..cda6d91 100644
--- a/tests/unit/DocBlock/DescriptionTest.php
+++ b/tests/unit/DocBlock/DescriptionTest.php
@@ -104,6 +104,18 @@ class DescriptionTest extends TestCase
$this->assertSame($tag2, $actualTags[1]);
}
+ /**
+ * @covers ::getBodyTemplate
+ */
+ public function testDescriptionBodyTemplateGetter() : void
+ {
+ $body = 'See https://github.com/phpDocumentor/ReflectionDocBlock/pull/171 for more information';
+
+ $fixture = new Description($body, []);
+
+ $this->assertSame($body, $fixture->getBodyTemplate());
+ }
+
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag