Skip to content

Commit 198231b

Browse files
Improve test suite
* [a] add tests utilitising Docker This adds a dependancy on Docker being installed * [f] add Docker image name * [f] correct image name * [f] remove container name * [f] re-introduce container name * [ch] add container name to travis build * [ch] remove travis `before_script` * [ch] add unit tests to suite * [ch] correct code sniffer cmd
1 parent 7f4cfe8 commit 198231b

File tree

8 files changed

+1237
-28
lines changed

8 files changed

+1237
-28
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
language: php
22

3+
services:
4+
- docker
5+
6+
after_install:
7+
- docker stop reactive_slim
8+
- docker rm reactive_slim
9+
310
php:
411
- 7.0
512
- 7.1
@@ -9,5 +16,6 @@ before_script:
916
- travis_retry composer install --no-interaction --prefer-source
1017

1118
script:
12-
- ./bin/phpcs src --standard=psr2-override.xml
19+
- ./bin/phpcs -p --standard=psr2-override.xml src
1320
- ./bin/phpspec r
21+
- ./bin/phpunit -c ./test/phpunit.xml.dist ./test/

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM php:7.0-alpine
2+
3+
COPY . /var/app
4+
WORKDIR /var/app
5+
6+
RUN apk update
7+
RUN apk add --update zlib-dev
8+
RUN docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) iconv
9+
RUN rm -rf /tmp/*
10+
RUN chmod +x ./test/Integration/ServerStub.php
11+
12+
EXPOSE 1351
13+
14+
ENTRYPOINT php ./test/Integration/ServerStub.php

composer.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"zendframework/zend-diactoros": "^1.4"
2323
},
2424
"require-dev": {
25+
"guzzlehttp/guzzle": "^6.2",
2526
"phpspec/phpspec": "^3.4",
27+
"phpunit/phpunit": "^6.1",
2628
"sebastianfeldmann/captainhook": "^2.0",
2729
"squizlabs/php_codesniffer": "^2.3"
2830
},
@@ -45,22 +47,27 @@
4547
},
4648
"autoload-dev": {
4749
"psr-4": {
48-
"ReactiveSlim\\": "tests"
50+
"ReactiveSlim\\Test\\": "test"
4951
}
5052
},
5153
"config": {
5254
"bin-dir": "./bin",
5355
"sort-packages": true
5456
},
5557
"scripts": {
56-
"test": "phpspec r",
58+
"docker-build": "docker build -t nigelgreenway/reactive-slim .",
59+
"docker-run": "docker run -d -p 1351:1351 --name reactive_slim nigelgreenway/reactive-slim",
60+
"docker-start": "docker start reactive_slim",
61+
"docker-stop": "docker stop reactive_slim",
62+
"test": "phpspec r && phpunit -c ./test/phpunit.xml.dist ./test",
5763
"check-style": "phpcs -p --standard=psr2-override.xml --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src",
5864
"fix-style": "phpcbf -p --standard=psr2-override.xml --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src",
59-
"clean": "rm -r ./{vendor,bin}",
65+
"clean": "rm -r ./{vendor,bin} && docker stop reactive_slim && docker rm reactive_slim",
6066
"post-install-cmd": [
6167
"captainhook install",
6268
"composer check-style",
63-
"composer test"
69+
"composer docker-build",
70+
"composer docker-run"
6471
]
6572
}
6673
}

0 commit comments

Comments
 (0)