Skip to content

Commit 544ef66

Browse files
authored
Merge pull request #250 from clue-labs/integration
Improve test suite with improved directory structure for integration tests
2 parents 73cb1cc + 1723f85 commit 544ef66

15 files changed

Lines changed: 45 additions & 42 deletions

File tree

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/.github/workflows/ export-ignore
55
/.gitignore export-ignore
66
/docs/ export-ignore
7-
/examples/ export-ignore
87
/mkdocs.yml export-ignore
98
/phpstan.neon.dist export-ignore
109
/phpunit.xml.dist export-ignore

.github/workflows/ci.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ jobs:
8383
- uses: shivammathur/setup-php@v2
8484
with:
8585
php-version: ${{ matrix.php }}
86-
- run: composer install -d tests/install-as-dep/
87-
- run: php tests/install-as-dep/public/index.php &
86+
- run: composer install -d tests/integration/
87+
- run: php tests/integration/public/index.php &
8888
- run: bash tests/await.sh
89-
- run: bash tests/acceptance.sh
89+
- run: bash tests/integration.bash
9090

9191
Docker:
9292
name: Docker (${{ matrix.dockerfile }})
@@ -101,11 +101,11 @@ jobs:
101101
- uses: shivammathur/setup-php@v2
102102
with:
103103
php-version: 8.3
104-
- run: composer install -d tests/install-as-dep/
105-
- run: docker build -f tests/${{ matrix.dockerfile }} tests/install-as-dep/
106-
- run: docker run -d -p 8080:8080 -v "$PWD/examples/index.php":/app/public/index.php -v "$PWD/composer.json":/app/composer.json -v "$PWD/LICENSE":/app/LICENSE -v "$PWD/tests/":/app/tests/ $(docker images -q | head -n1)
104+
- run: composer install -d tests/integration/
105+
- run: docker build -f tests/integration/${{ matrix.dockerfile }} tests/integration/
106+
- run: docker run -d -p 8080:8080 -v "$PWD/composer.json":/app/composer.json $(docker images -q | head -n1)
107107
- run: bash tests/await.sh
108-
- run: bash tests/acceptance.sh
108+
- run: bash tests/integration.bash
109109
- run: docker stop $(docker ps -qn1)
110110
- run: docker logs $(docker ps -qn1)
111111
if: ${{ always() }}
@@ -129,11 +129,13 @@ jobs:
129129
- uses: shivammathur/setup-php@v2
130130
with:
131131
php-version: ${{ matrix.php }}
132-
- run: composer install -d tests/install-as-dep/
133-
- run: docker run -d -v "$PWD/tests/install-as-dep/":/home/framework-x/ -v "$PWD/examples/index.php":/home/framework-x/public/index.php -v "$PWD/LICENSE":/home/framework-x/LICENSE -v "$PWD/tests/":/home/framework-x/tests/ php:${{ matrix.php }}-fpm
134-
- run: docker run -d -p 80:80 --link $(docker ps -qn1):php -v "$PWD/tests/install-as-dep/":/home/framework-x/ -v "$PWD"/examples/nginx/nginx.conf:/etc/nginx/conf.d/default.conf nginx:stable-alpine
132+
- run: composer install -d tests/integration/
133+
- run: docker run -d -v "$PWD/tests/integration/":/home/framework-x/ php:${{ matrix.php }}-fpm
134+
- run: docker run -d -p 80:80 --link $(docker ps -qn1):php -v "$PWD/tests/integration/":/home/framework-x/ -v "$PWD"/tests/integration/nginx-fpm.conf:/etc/nginx/conf.d/default.conf nginx:stable-alpine
135135
- run: bash tests/await.sh http://localhost
136-
- run: bash tests/acceptance.sh http://localhost
136+
- run: bash tests/integration.bash http://localhost
137+
- run: docker logs $(docker ps -qn1)
138+
if: ${{ always() }}
137139

138140
Apache-webserver:
139141
name: Apache webserver (PHP ${{ matrix.php }})
@@ -154,10 +156,12 @@ jobs:
154156
- uses: shivammathur/setup-php@v2
155157
with:
156158
php-version: ${{ matrix.php }}
157-
- run: composer install -d tests/install-as-dep/
158-
- run: docker run -d -p 80:80 -v "$PWD/tests/install-as-dep/":/home/framework-x/ -v "$PWD/examples/index.php":/home/framework-x/public/index.php -v "$PWD/LICENSE":/home/framework-x/LICENSE -v "$PWD/tests/":/home/framework-x/tests/ -v "$PWD/examples/apache/.htaccess":/home/framework-x/public/.htaccess php:${{ matrix.php }}-apache sh -c "rmdir /var/www/html;ln -s /home/framework-x/public /var/www/html;ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
159+
- run: composer install -d tests/integration/
160+
- run: docker run -d -p 80:80 -v "$PWD/tests/integration/":/home/framework-x/ php:${{ matrix.php }}-apache sh -c "rmdir /var/www/html;ln -s /home/framework-x/public /var/www/html;ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
159161
- run: bash tests/await.sh http://localhost
160-
- run: bash tests/acceptance.sh http://localhost
162+
- run: bash tests/integration.bash http://localhost
163+
- run: docker logs $(docker ps -qn1)
164+
if: ${{ always() }}
161165

162166
PHP-webserver:
163167
name: PHP webserver (PHP ${{ matrix.php }})
@@ -178,7 +182,7 @@ jobs:
178182
- uses: shivammathur/setup-php@v2
179183
with:
180184
php-version: ${{ matrix.php }}
181-
- run: composer install -d tests/install-as-dep/
182-
- run: php -S localhost:8080 tests/install-as-dep/public/index.php &
185+
- run: composer install -d tests/integration/
186+
- run: php -S localhost:8080 tests/integration/public/index.php &
183187
- run: bash tests/await.sh
184-
- run: bash tests/acceptance.sh
188+
- run: bash tests/integration.bash

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ generate a code coverage report locally like this:
127127
$ XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text
128128
```
129129

130-
Additionally, you can run some simple acceptance tests to verify the framework
131-
examples work as expected behind your web server. Use your web server of choice
132-
(see deployment documentation) and execute the tests with the URL to your
133-
installation like this:
130+
Additionally, you can run our sophisticated integration tests to verify the
131+
framework examples work as expected behind your web server. Use your web server
132+
of choice (see deployment documentation) and execute the tests with the URL to
133+
your installation like this:
134134

135135
```bash
136-
$ php examples/index.php
137-
$ tests/acceptance.sh http://localhost:8080
136+
$ php tests/integration/public/index.php
137+
$ tests/integration.bash http://localhost:8080
138138
```
139139

140140
## License

phpstan.neon.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ parameters:
22
level: max
33

44
paths:
5-
- examples/
65
- src/
76
- tests/
87

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<testsuites>
1212
<testsuite name="Framework X test suite">
1313
<directory>./tests/</directory>
14-
<exclude>./tests/install-as-dep/</exclude>
14+
<exclude>./tests/integration/</exclude>
1515
</testsuite>
1616
</testsuites>
1717
<coverage>

tests/install-as-dep/public/index.php

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ notmatch() {
1818
skipif() {
1919
echo "$out" | grep "$@" >/dev/null && echo -n S && return 1 || return 0
2020
}
21+
skipifnot() {
22+
echo "$out" | grep "$@" >/dev/null && return 0 || echo -n S && return 1
23+
}
2124

2225
out=$(curl -v $base/ 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain; charset=utf-8[\r\n]"
2326
out=$(curl -v $base/invalid 2>&1); match "HTTP/.* 404" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
@@ -81,15 +84,15 @@ out=$(curl -v $base/users 2>&1); match "HTTP/.* 404"
8184
out=$(curl -v $base/users/ 2>&1); match "HTTP/.* 404"
8285
out=$(curl -v $base/users/a/b 2>&1); match "HTTP/.* 404"
8386

84-
out=$(curl -v $base/LICENSE 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain[\r\n]"
87+
out=$(curl -v $base/robots.txt 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain[\r\n]"
8588
out=$(curl -v $base/source 2>&1); match -i "Location: /source/" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
8689
out=$(curl -v $base/source/ 2>&1); match "HTTP/.* 200"
8790
out=$(curl -v $base/source/composer.json 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: application/json[\r\n]"
88-
out=$(curl -v $base/source/LICENSE 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain[\r\n]"
89-
out=$(curl -v $base/source/LICENSE/ 2>&1); match -i "Location: ../LICENSE" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
90-
out=$(curl -v $base/source/LICENSE// 2>&1); match "HTTP/.* 404"
91-
out=$(curl -v $base/source//LICENSE 2>&1); match "HTTP/.* 404"
92-
out=$(curl -v $base/source/tests 2>&1); match -i "Location: tests/" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
91+
out=$(curl -v $base/source/public/robots.txt 2>&1); match "HTTP/.* 200" && match -iP "Content-Type: text/plain[\r\n]"
92+
out=$(curl -v $base/source/public/robots.txt/ 2>&1); match -i "Location: ../robots.txt" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
93+
out=$(curl -v $base/source/public/robots.txt// 2>&1); match "HTTP/.* 404"
94+
out=$(curl -v $base/source//public/robots.txt 2>&1); match "HTTP/.* 404"
95+
out=$(curl -v $base/source/public 2>&1); match -i "Location: public/" && match -iP "Content-Type: text/html; charset=utf-8[\r\n]"
9396
out=$(curl -v $base/source/invalid 2>&1); match "HTTP/.* 404"
9497
out=$(curl -v $base/source/bin%00ary 2>&1); match "HTTP/.* 40[40]" # expects 404, but not processed with nginx (400) and Apache (404)
9598

@@ -121,7 +124,7 @@ out=$(curl -v $base/headers -H 'Content-Length: 0' 2>&1); match "HTTP/.* 200"
121124
out=$(curl -v $base/headers -H 'Empty;' 2>&1); match "HTTP/.* 200" && match "\"Empty\": \"\""
122125
out=$(curl -v $base/headers -H 'Content-Type;' 2>&1); skipif "Server: Apache" && match "HTTP/.* 200" && match "\"Content-Type\": \"\"" # skip Apache (discards empty Content-Type)
123126
out=$(curl -v $base/headers -H 'DNT: 1' 2>&1); skipif "Server: nginx" && match "HTTP/.* 200" && match "\"DNT\"" && notmatch "\"Dnt\"" # skip nginx which doesn't report original case (DNT->Dnt)
124-
out=$(curl -v $base/headers -H 'V: a' -H 'V: b' 2>&1); skipif "Server: nginx" && skipif -v "Server:" && match "HTTP/.* 200" && match "\"V\": \"a, b\"" # skip nginx (last only) and PHP webserver (first only)
127+
out=$(curl -v $base/headers -H 'V: a' -H 'V: b' 2>&1); skipif "Server: nginx" && skipifnot "Server:" && match "HTTP/.* 200" && match "\"V\": \"a, b\"" # skip nginx (last only) and PHP webserver (first only)
125128

126129
out=$(curl -v $base/set-cookie 2>&1); match "HTTP/.* 200" && match "Set-Cookie: 1=1" && match "Set-Cookie: 2=2"
127130

0 commit comments

Comments
 (0)