Skip to content

Commit c50a167

Browse files
authoredJan 15, 2024
improved local test methods (#18)
1 parent 784438c commit c50a167

15 files changed

+178
-26
lines changed
 

‎.docker/Dockerfile-php7.0

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:7.0-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.docker/Dockerfile-php7.1

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:7.1-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.docker/Dockerfile-php7.2

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:7.2-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.docker/Dockerfile-php7.3

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:7.3-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.docker/Dockerfile-php7.4

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:7.4-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.docker/Dockerfile-php8.0

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:8.0-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.docker/Dockerfile-php8.1

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:8.1-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.docker/Dockerfile-php8.2

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:8.2-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.docker/Dockerfile-php8.3

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:8.3-cli-alpine
2+
3+
COPY ./../.. /usr/src/myapp
4+
WORKDIR /usr/src/myapp
5+
6+
RUN apk --no-cache add curl zip
7+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
8+
RUN composer install

‎.dockerignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.docker
2+
.dockerignore
3+
.git
4+
.github
5+
composer.lock
6+
docker-compose.yml
7+
vendor/

‎DEVELOPMENT.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Development
2+
3+
When a change is made, each php version should be tested in isolation, because depending on the PHP version, composer is downloading different files.
4+
5+
The Github-ci will automatically performs the phpunit tests as a final check.
6+
7+
For local testing, this can be done with the prepared docker images, using docker compose.
8+
9+
### Running local PHPUnit tests
10+
11+
```
12+
./docker-run-tests.sh
13+
```
14+
15+
### Rebuild docker images
16+
17+
```
18+
docker compose build
19+
```
20+
21+
### Remove orphans
22+
23+
```
24+
docker compose down --remove-orphans
25+
```

‎README.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
composer require rboonzaijer/php-array-to-xml ^2.0
2828
```
2929

30-
Load the vendor files (these already loaded if you are using something like Symfony or Laravel)
30+
Require the vendor files (these already loaded if you are using something like Symfony or Laravel)
3131
```php
3232
require __DIR__ . '/vendor/autoload.php';
3333
```
@@ -469,14 +469,6 @@ Result (prettified):
469469
</root>
470470
```
471471

472-
# PHPUnit Tests
473-
Use a specific configuration file, depending on your php version:
474-
```
475-
./vendor/bin/phpunit --configuration ./tests/phpunit-7.0.xml
476-
./vendor/bin/phpunit --configuration ./tests/phpunit-7.1.xml
477-
./vendor/bin/phpunit --configuration ./tests/phpunit-7.2.xml
478-
./vendor/bin/phpunit --configuration ./tests/phpunit-7.3.xml
479-
./vendor/bin/phpunit --configuration ./tests/phpunit-7.4.xml
480-
./vendor/bin/phpunit --configuration ./tests/phpunit-8.0.xml
481-
./vendor/bin/phpunit --configuration ./tests/phpunit-8.1.xml
482-
```
472+
## Development
473+
474+
- [DEVELOPMENT.md](DEVELOPMENT.md)

‎docker-compose.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: "3"
2+
3+
services:
4+
5+
php8.3:
6+
build:
7+
context: .
8+
dockerfile: .docker/Dockerfile-php8.3
9+
10+
php8.2:
11+
build:
12+
context: .
13+
dockerfile: .docker/Dockerfile-php8.2
14+
15+
php8.1:
16+
build:
17+
context: .
18+
dockerfile: .docker/Dockerfile-php8.1
19+
20+
php8.0:
21+
build:
22+
context: .
23+
dockerfile: .docker/Dockerfile-php8.0
24+
25+
php7.4:
26+
build:
27+
context: .
28+
dockerfile: .docker/Dockerfile-php7.4
29+
30+
php7.3:
31+
build:
32+
context: .
33+
dockerfile: .docker/Dockerfile-php7.3
34+
35+
php7.2:
36+
build:
37+
context: .
38+
dockerfile: .docker/Dockerfile-php7.2
39+
40+
php7.1:
41+
build:
42+
context: .
43+
dockerfile: .docker/Dockerfile-php7.1
44+
45+
php7.0:
46+
build:
47+
context: .
48+
dockerfile: .docker/Dockerfile-php7.0

‎docker-run-tests.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
docker compose run --rm php7.0 php ./vendor/bin/phpunit -c tests/phpunit-7.0.xml -v && \
2+
docker compose run --rm php7.1 php ./vendor/bin/phpunit -c tests/phpunit-7.1.xml -v && \
3+
docker compose run --rm php7.2 php ./vendor/bin/phpunit -c tests/phpunit-7.2.xml -v && \
4+
docker compose run --rm php7.3 php ./vendor/bin/phpunit -c tests/phpunit-7.3.xml -v && \
5+
docker compose run --rm php7.4 php ./vendor/bin/phpunit -c tests/phpunit-7.4.xml -v && \
6+
docker compose run --rm php8.0 php ./vendor/bin/phpunit -c tests/phpunit-8.0.xml -v && \
7+
docker compose run --rm php8.1 php ./vendor/bin/phpunit -c tests/phpunit-8.1.xml && \
8+
docker compose run --rm php8.2 php ./vendor/bin/phpunit -c tests/phpunit-8.2.xml && \
9+
docker compose run --rm php8.3 php ./vendor/bin/phpunit -c tests/phpunit-8.3.xml && \
10+
echo -e "\n\ndone.\n"

‎tests/phpunit-8.1.xml

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!-- PHPUnit 9 >= PHP 7.3 (https://phpunit.de/supported-versions.html) -->
2+
<!-- PHPUnit 10 >= PHP 8.1 (https://phpunit.de/supported-versions.html) -->
33
<phpunit
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
backupGlobals="false"
6-
backupStaticAttributes="false"
76
bootstrap="./../vendor/autoload.php"
87
colors="true"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
128
processIsolation="false"
139
stopOnFailure="false"
14-
cacheResult ="false"
15-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
16-
<coverage>
10+
cacheResult="false"
11+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
12+
cacheDirectory=".phpunit.cache"
13+
backupStaticProperties="false">
14+
<testsuites>
15+
<testsuite name="PhpArrayToXml Test Suite">
16+
<directory>./../tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
<source>
1720
<include>
1821
<directory>./../src</directory>
1922
</include>
2023
<exclude>
2124
<directory>./../vendor</directory>
2225
<directory>./../tests</directory>
2326
</exclude>
24-
</coverage>
25-
<testsuites>
26-
<testsuite name="PhpArrayToXml Test Suite">
27-
<directory>./../tests/</directory>
28-
</testsuite>
29-
</testsuites>
27+
</source>
3028
</phpunit>

0 commit comments

Comments
 (0)
Please sign in to comment.