Skip to content

Commit

Permalink
Update and improve Behat tests
Browse files Browse the repository at this point in the history
* Bump Behat-version and add imbo/behat-api-extension
* Move behat.yml to the default location
* Add composer script for starting PHPs built in httpd for the Behat tests
* Rename Behat configuration file to .dist so developers can have local configuration files
* Install micheh/psr7-cache to easily check if a response is cacheable or not. This functionality was earlier present in Guzzle, but has been removed.
* Move the PHPUnit configuration files to root. Resolves #507
  • Loading branch information
christeredvartsen committed Apr 2, 2017
1 parent 8bff9d6 commit 384ea83
Show file tree
Hide file tree
Showing 59 changed files with 7,043 additions and 3,448 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -5,4 +5,6 @@ docs/_build
.lintcache .lintcache
*.log *.log
public/.htaccess public/.htaccess
.idea .idea
behat.yml
phpunit.xml
8 changes: 6 additions & 2 deletions .travis.yml
Expand Up @@ -37,12 +37,16 @@ before_install:


before_script: before_script:
- phpenv config-rm xdebug.ini - phpenv config-rm xdebug.ini
- echo 'always_populate_raw_post_data = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- composer self-update - composer self-update
- composer lint
- composer prepare
- composer install --prefer-dist - composer install --prefer-dist
- composer start-httpd-for-behat-tests


script: script:
- ./vendor/bin/phpunit --verbose -c tests/phpunit/phpunit.xml.travis - ./vendor/bin/phpunit --verbose -c phpunit.xml.travis --stop-on-failure
- ./vendor/bin/behat --strict --profile no-cc --config tests/behat/behat.yml - ./vendor/bin/behat --strict --stop-on-failure


after_failure: after_failure:
- echo "Tests failed - httpd log follows" - echo "Tests failed - httpd log follows"
Expand Down
10 changes: 3 additions & 7 deletions CONTRIBUTING.md
Expand Up @@ -8,28 +8,24 @@ If you wish to contribute to Imbo, please read the following resources first:


## Running tests ## Running tests


Imbo has both [Behat](http://docs.behat.org/en/v2.5/) and [PHPUnit](https://phpunit.de/) tests, and when adding new features or fixing bugs you are required to add relevant test cases. Remember to install the development requirements using [Composer](https://getcomposer.org/) before running the tests: Imbo has both [Behat](http://behat.org) and [PHPUnit](https://phpunit.de/) tests, and when adding new features or fixing bugs you are required to add relevant test cases. Remember to install dependencies before running the tests:


``` ```
composer install --dev composer install
``` ```


### Behat ### Behat


``` ```
./vendor/bin/behat --strict --profile no-cc --config tests/behat/behat.yml ./vendor/bin/behat --strict
``` ```


The `--profile no-cc` arguments will disable the generation of code coverage. If you skip these arguments you will get code covarage of the Behat tests.

### PHPUnit ### PHPUnit


``` ```
./vendor/bin/phpunit --verbose -c tests/phpunit ./vendor/bin/phpunit --verbose -c tests/phpunit
``` ```


Include `--coverage-html <path>` if you want to generate code coverage report of the tests.

## Writing documentation ## Writing documentation


Imbo uses [Read the docs](https://readthedocs.org/projects/imbo/) for documentation, and all docs are located in the `docs` dir. The docs are written using [Sphinx](http://sphinx-doc.org/), and if you are contributing new features please add relevant docs. Imbo uses [Read the docs](https://readthedocs.org/projects/imbo/) for documentation, and all docs are located in the `docs` dir. The docs are written using [Sphinx](http://sphinx-doc.org/), and if you are contributing new features please add relevant docs.
11 changes: 11 additions & 0 deletions behat.yml.dist
@@ -0,0 +1,11 @@
default:
autoload:
'': %paths.base%/tests/behat/features/bootstrap
suites:
default:
paths: [%paths.base%/tests/behat/features]

extensions:
Imbo\BehatApiExtension:
apiClient:
base_uri: http://localhost:8080
19 changes: 10 additions & 9 deletions composer.json
Expand Up @@ -36,15 +36,16 @@
"require-dev": { "require-dev": {
"mikey179/vfsStream": "^1.5.0", "mikey179/vfsStream": "^1.5.0",
"phpunit/phpunit": "^5.6", "phpunit/phpunit": "^5.6",
"behat/behat": "^2.0", "behat/behat": "^3.2",
"guzzle/guzzle": "^3.9.3",
"phploc/phploc": "^3.0", "phploc/phploc": "^3.0",
"sebastian/phpcpd": "^2.0", "sebastian/phpcpd": "^2.0",
"phpmd/phpmd": "^2.4", "phpmd/phpmd": "^2.4",
"squizlabs/php_codesniffer": "^2.7", "squizlabs/php_codesniffer": "^2.7",
"imbo/imbo-phpcs-standard": "^1.4", "imbo/imbo-phpcs-standard": "^1.4",
"phpdocumentor/phpdocumentor": "^2.9", "phpdocumentor/phpdocumentor": "^2.9",
"cwhite92/b2-sdk-php": "^1.2" "cwhite92/b2-sdk-php": "^1.2",
"imbo/behat-api-extension": "^2.0",
"micheh/psr7-cache": "^0.5"
}, },
"suggest": { "suggest": {
"ext-mongo": "Enables usage of MongoDB and GridFS as database and store. Recommended version: >=1.4.0", "ext-mongo": "Enables usage of MongoDB and GridFS as database and store. Recommended version: >=1.4.0",
Expand Down Expand Up @@ -77,12 +78,11 @@
"mkdir build", "mkdir build",
"mkdir build/coverage", "mkdir build/coverage",
"mkdir build/logs", "mkdir build/logs",
"mkdir build/docs", "mkdir build/docs"
"mkdir build/code-browser",
"mkdir build/pdepend"
], ],
"test-phpunit": "vendor/bin/phpunit --verbose -c tests/phpunit", "test-phpunit": "vendor/bin/phpunit --verbose",
"test-behat": "vendor/bin/behat --strict --config tests/behat/behat.yml", "test-phpunit-coverage": "vendor/bin/phpunit --verbose --coverage-html build/coverage",
"test-behat": "vendor/bin/behat --strict",
"test": [ "test": [
"@test-phpunit", "@test-phpunit",
"@test-behat" "@test-behat"
Expand All @@ -107,6 +107,7 @@
"docs": [ "docs": [
"cd docs; make spelling", "cd docs; make spelling",
"cd docs; make html" "cd docs; make html"
] ],
"start-httpd-for-behat-tests": "php -S localhost:8080 -t ./public tests/behat/router.php > build/logs/httpd.log 2>&1 &"
} }
} }

0 comments on commit 384ea83

Please sign in to comment.