Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Enhancement: Collect code coverage #1824

Merged
merged 3 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.build/
vendor
composer.lock
35 changes: 22 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ language: php

dist: precise

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- nightly
jobs:
include:
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
env: WITH_COVERAGE=true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably do not need to collect coverage on all builds - running on the latest version of PHP increases the likelihood that it's a fast run nonetheless.

- php: nightly

matrix:
allow_failures:
Expand All @@ -22,9 +24,16 @@ cache:
- $HOME/.composer/cache

before_install:
- phpenv config-rm xdebug.ini || true
- source .travis/xdebug.sh
- xdebug-disable

before_script:
- travis_retry composer install --no-interaction --prefer-dist
- travis_retry composer install --no-interaction --prefer-dist

script: make sniff test
script:
- make sniff
- if [[ "$WITH_COVERAGE" == "true" ]]; then xdebug-enable; fi
- if [[ "$WITH_COVERAGE" == "true" ]]; then make coverage; else make test; fi

after_success:
- if [[ "$WITH_COVERAGE" == "true" ]]; then bash <(curl -s https://codecov.io/bash); fi
22 changes: 22 additions & 0 deletions .travis/xdebug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# The problem is that we do not want to remove the configuration file, just disable it for a few tasks, then enable it
#
# For reference, see
#
# - https://docs.travis-ci.com/user/languages/php#Disabling-preinstalled-PHP-extensions
# - https://docs.travis-ci.com/user/languages/php#Custom-PHP-configuration

config="/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini"

function xdebug-disable() {
if [[ -f $config ]]; then
mv $config "$config.bak"
fi
}

function xdebug-enable() {
if [[ -f "$config.bak" ]]; then
mv "$config.bak" $config
fi
}
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
.PHONY: build fix help sniff test
.PHONY: build coverage fix help sniff test

help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build: fix test ## Runs fix and test targets

coverage: vendor/autoload.php ## Collects coverage with phpunit
vendor/bin/phpunit --coverage-text --coverage-clover=.build/logs/clover.xml

fix: vendor/autoload.php ## Fixes code style issues with phpcbf
vendor/bin/phpcbf --standard=PSR2 src

Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@
<directory>./test/Faker/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Faker

[![Code Coverage](https://codecov.io/gh/fzaninotto/Faker/branch/master/graph/badge.svg)](https://codecov.io/gh/fzaninotto/Faker)

Faker is a PHP library that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.

Faker is heavily inspired by Perl's [Data::Faker](http://search.cpan.org/~jasonk/Data-Faker-0.07/), and by ruby's [Faker](https://rubygems.org/gems/faker).
Expand Down Expand Up @@ -53,7 +55,7 @@ composer require fzaninotto/faker

### Autoloading

Faker supports both `PSR-0` as `PSR-4` autoloaders.
Faker supports both `PSR-0` as `PSR-4` autoloaders.
```php
<?php
# When installed via composer
Expand Down