Permalink
Browse files

Update and improve Behat tests

* 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 384ea838eb0ae2569196996d03e82ac4261176f7
Showing with 7,043 additions and 3,448 deletions.
  1. +3 −1 .gitignore
  2. +6 −2 .travis.yml
  3. +3 −7 CONTRIBUTING.md
  4. +11 −0 behat.yml.dist
  5. +10 −9 composer.json
  6. +754 −486 composer.lock
  7. +8 −7 {tests/phpunit → }/phpunit.xml.dist
  8. +3 −3 {tests/phpunit → }/phpunit.xml.travis
  9. +0 −1 tests/.gitignore
  10. +98 −0 tests/behat/README.md
  11. +0 −31 tests/behat/behat.yml
  12. +0 −739 tests/behat/bootstrap/ImboContext.php
  13. +0 −554 tests/behat/bootstrap/RESTContext.php
  14. +159 −112 tests/behat/features/access-control-keys.feature
  15. +16 −16 tests/behat/features/access-control-mutable.feature
  16. +34 −30 tests/behat/features/access-control.feature
  17. +28 −31 tests/behat/features/access-token.feature
  18. +47 −25 tests/behat/features/authenticate-write-operations.feature
  19. +6 −7 tests/behat/features/autorotate-event-listener.feature
  20. +1,787 −0 tests/behat/features/bootstrap/FeatureContext.php
  21. +36 −40 tests/behat/features/border-transformation.feature
  22. +30 −39 tests/behat/features/client-caching.feature
  23. +35 −25 tests/behat/features/content-negotiation.feature
  24. +54 −72 tests/behat/features/cors-event-listener.feature
  25. +6 −6 tests/behat/features/custom-event-listeners.feature
  26. +3 −3 tests/behat/features/custom-resource.feature
  27. +23 −27 tests/behat/features/draw-pois-transformation.feature
  28. +20 −21 tests/behat/features/etags.feature
  29. +30 −40 tests/behat/features/exif-metadata-event-listener.feature
  30. +116 −33 tests/behat/features/global-images.feature
  31. +30 −29 tests/behat/features/group.feature
  32. +40 −24 tests/behat/features/groups.feature
  33. +36 −48 tests/behat/features/head.feature
  34. +25 −15 tests/behat/features/image-identifier-generator-md5.feature
  35. +53 −46 tests/behat/features/image-transformation-cache-listener.feature
  36. +132 −146 tests/behat/features/image-transformations.feature
  37. +29 −53 tests/behat/features/image-variations.feature
  38. +48 −32 tests/behat/features/image.feature
  39. +176 −108 tests/behat/features/images.feature
  40. +16 −18 tests/behat/features/index.feature
  41. +9 −11 tests/behat/features/level-transformation.feature
  42. +31 −20 tests/behat/features/max-image-size-event-listener.feature
  43. +35 −188 tests/behat/features/metadata.feature
  44. +32 −23 tests/behat/features/shorturls.feature
  45. +49 −62 tests/behat/features/smartsize-transformation.feature
  46. +60 −59 tests/behat/features/stats.feature
  47. +49 −22 tests/behat/features/status.feature
  48. +4 −6 tests/behat/features/strip-exif-transformation.feature
  49. +16 −19 tests/behat/features/user.feature
  50. +12 −15 tests/behat/features/varnish-hashtwo-listener.feature
  51. +15 −17 tests/behat/features/watermark-transformation.feature
  52. +2 −0 tests/behat/fixtures/access-control-mutable.php
  53. +1 −5 tests/behat/imbo-configs/access-control.php
  54. +14 −12 tests/behat/imbo-configs/config.testing.php
  55. +17 −12 tests/behat/imbo-configs/stats-access-and-custom-stats.php
  56. +19 −20 tests/behat/imbo-configs/status.php
  57. +3 −71 tests/behat/router.php
  58. +4 −0 tests/phpunit/bootstrap.php
  59. +2,760 −0 tests/phpunit/unit/FeatureContextTest.php
View
@@ -5,4 +5,6 @@ docs/_build
.lintcache
*.log
public/.htaccess
-.idea
+.idea
+behat.yml
+phpunit.xml
View
@@ -37,12 +37,16 @@ before_install:
before_script:
- 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 lint
+ - composer prepare
- composer install --prefer-dist
+ - composer start-httpd-for-behat-tests
script:
- - ./vendor/bin/phpunit --verbose -c tests/phpunit/phpunit.xml.travis
- - ./vendor/bin/behat --strict --profile no-cc --config tests/behat/behat.yml
+ - ./vendor/bin/phpunit --verbose -c phpunit.xml.travis --stop-on-failure
+ - ./vendor/bin/behat --strict --stop-on-failure
after_failure:
- echo "Tests failed - httpd log follows"
View
@@ -8,28 +8,24 @@ If you wish to contribute to Imbo, please read the following resources first:
## 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
```
-./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
```
./vendor/bin/phpunit --verbose -c tests/phpunit
```
-Include `--coverage-html <path>` if you want to generate code coverage report of the tests.
-
## 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.
View
@@ -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
View
@@ -36,15 +36,16 @@
"require-dev": {
"mikey179/vfsStream": "^1.5.0",
"phpunit/phpunit": "^5.6",
- "behat/behat": "^2.0",
- "guzzle/guzzle": "^3.9.3",
+ "behat/behat": "^3.2",
"phploc/phploc": "^3.0",
"sebastian/phpcpd": "^2.0",
"phpmd/phpmd": "^2.4",
"squizlabs/php_codesniffer": "^2.7",
"imbo/imbo-phpcs-standard": "^1.4",
"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": {
"ext-mongo": "Enables usage of MongoDB and GridFS as database and store. Recommended version: >=1.4.0",
@@ -77,12 +78,11 @@
"mkdir build",
"mkdir build/coverage",
"mkdir build/logs",
- "mkdir build/docs",
- "mkdir build/code-browser",
- "mkdir build/pdepend"
+ "mkdir build/docs"
],
- "test-phpunit": "vendor/bin/phpunit --verbose -c tests/phpunit",
- "test-behat": "vendor/bin/behat --strict --config tests/behat/behat.yml",
+ "test-phpunit": "vendor/bin/phpunit --verbose",
+ "test-phpunit-coverage": "vendor/bin/phpunit --verbose --coverage-html build/coverage",
+ "test-behat": "vendor/bin/behat --strict",
"test": [
"@test-phpunit",
"@test-behat"
@@ -107,6 +107,7 @@
"docs": [
"cd docs; make spelling",
"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 &"
}
}
Oops, something went wrong.

0 comments on commit 384ea83

Please sign in to comment.