Skip to content

Commit

Permalink
Merge pull request #43 from stevegrunwell/feature/restore-code-coverage
Browse files Browse the repository at this point in the history
Re-enable code coverage reporting to Coveralls
  • Loading branch information
stevegrunwell authored Dec 2, 2023
2 parents c75b965 + 30ee855 commit 43c10c7
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This project uses [the PSR-2 coding standards](http://www.php-fig.org/psr/psr-2/
[PHPUnit](https://phpunit.de/) is included as a development dependency, and should be run regularly. When submitting changes, please be sure to add or update unit tests accordingly. You may run unit tests at any time by running:

```bash
$ ./vendor/bin/phpunit
$ composer test
```

#### Code coverage
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Code Coverage

on: [pull_request]

jobs:
coverage:
name: Report code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: xdebug

- name: Install Composer dependencies
uses: ramsey/composer-install@v2

- name: Run test suite
run: vendor/bin/simple-phpunit --coverage-text --coverage-clover=tests/coverage

- name: Publish to Coveralls
uses: coverallsapp/github-action@v2
with:
files: tests/coverage
format: clover
fail-on-error: false
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
*.DS_Store
tests/coverage
vendor
.phpunit.result.cache
.vscode
tests/coverage
vendor

# The composer.lock file is not needed, as this is a library whose dependencies
# will depend on the version of PHP being used.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"simple-phpunit --testdox"
],
"test-coverage": [
"phpdbg -qrr -d memory_limit=-1 ./vendor/bin/simple-phpunit --coverage-html=tests/coverage --colors=always"
"XDEBUG_MODE=coverage ./vendor/bin/simple-phpunit --coverage-html=tests/coverage --colors=always"
]
},
"scripts-descriptions": {
Expand Down
8 changes: 4 additions & 4 deletions src/MarkupAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function assertElementContains($contents, $selector = '', $markup = '', $
{
$method = method_exists($this, 'assertStringContainsString')
? 'assertStringContainsString'
: 'assertContains';
: 'assertContains'; // @codeCoverageIgnore

$this->$method(
$contents,
Expand All @@ -153,7 +153,7 @@ public function assertElementNotContains($contents, $selector = '', $markup = ''
{
$method = method_exists($this, 'assertStringNotContainsString')
? 'assertStringNotContainsString'
: 'assertNotContains';
: 'assertNotContains'; // @codeCoverageIgnore

$this->$method(
$contents,
Expand All @@ -178,7 +178,7 @@ public function assertElementRegExp($regexp, $selector = '', $markup = '', $mess
{
$method = method_exists($this, 'assertMatchesRegularExpression')
? 'assertMatchesRegularExpression'
: 'assertRegExp';
: 'assertRegExp'; // @codeCoverageIgnore

$this->$method(
$regexp,
Expand All @@ -203,7 +203,7 @@ public function assertElementNotRegExp($regexp, $selector = '', $markup = '', $m
{
$method = method_exists($this, 'assertDoesNotMatchRegularExpression')
? 'assertDoesNotMatchRegularExpression'
: 'assertNotRegExp';
: 'assertNotRegExp'; // @codeCoverageIgnore

$this->$method(
$regexp,
Expand Down

0 comments on commit 43c10c7

Please sign in to comment.