Skip to content

improved local test methods #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php7.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:7.0-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php7.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:7.1-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php7.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:7.2-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php7.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:7.3-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php7.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:7.4-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php8.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:8.0-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php8.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:8.1-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php8.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:8.2-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
8 changes: 8 additions & 0 deletions .docker/Dockerfile-php8.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM php:8.3-cli-alpine

COPY ./../.. /usr/src/myapp
WORKDIR /usr/src/myapp

RUN apk --no-cache add curl zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.docker
.dockerignore
.git
.github
composer.lock
docker-compose.yml
vendor/
25 changes: 25 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Development

When a change is made, each php version should be tested in isolation, because depending on the PHP version, composer is downloading different files.

The Github-ci will automatically performs the phpunit tests as a final check.

For local testing, this can be done with the prepared docker images, using docker compose.

### Running local PHPUnit tests

```
./docker-run-tests.sh
```

### Rebuild docker images

```
docker compose build
```

### Remove orphans

```
docker compose down --remove-orphans
```
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
composer require rboonzaijer/php-array-to-xml ^2.0
```

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

# PHPUnit Tests
Use a specific configuration file, depending on your php version:
```
./vendor/bin/phpunit --configuration ./tests/phpunit-7.0.xml
./vendor/bin/phpunit --configuration ./tests/phpunit-7.1.xml
./vendor/bin/phpunit --configuration ./tests/phpunit-7.2.xml
./vendor/bin/phpunit --configuration ./tests/phpunit-7.3.xml
./vendor/bin/phpunit --configuration ./tests/phpunit-7.4.xml
./vendor/bin/phpunit --configuration ./tests/phpunit-8.0.xml
./vendor/bin/phpunit --configuration ./tests/phpunit-8.1.xml
```
## Development

- [DEVELOPMENT.md](DEVELOPMENT.md)
48 changes: 48 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "3"

services:

php8.3:
build:
context: .
dockerfile: .docker/Dockerfile-php8.3

php8.2:
build:
context: .
dockerfile: .docker/Dockerfile-php8.2

php8.1:
build:
context: .
dockerfile: .docker/Dockerfile-php8.1

php8.0:
build:
context: .
dockerfile: .docker/Dockerfile-php8.0

php7.4:
build:
context: .
dockerfile: .docker/Dockerfile-php7.4

php7.3:
build:
context: .
dockerfile: .docker/Dockerfile-php7.3

php7.2:
build:
context: .
dockerfile: .docker/Dockerfile-php7.2

php7.1:
build:
context: .
dockerfile: .docker/Dockerfile-php7.1

php7.0:
build:
context: .
dockerfile: .docker/Dockerfile-php7.0
10 changes: 10 additions & 0 deletions docker-run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
docker compose run --rm php7.0 php ./vendor/bin/phpunit -c tests/phpunit-7.0.xml -v && \
docker compose run --rm php7.1 php ./vendor/bin/phpunit -c tests/phpunit-7.1.xml -v && \
docker compose run --rm php7.2 php ./vendor/bin/phpunit -c tests/phpunit-7.2.xml -v && \
docker compose run --rm php7.3 php ./vendor/bin/phpunit -c tests/phpunit-7.3.xml -v && \
docker compose run --rm php7.4 php ./vendor/bin/phpunit -c tests/phpunit-7.4.xml -v && \
docker compose run --rm php8.0 php ./vendor/bin/phpunit -c tests/phpunit-8.0.xml -v && \
docker compose run --rm php8.1 php ./vendor/bin/phpunit -c tests/phpunit-8.1.xml && \
docker compose run --rm php8.2 php ./vendor/bin/phpunit -c tests/phpunit-8.2.xml && \
docker compose run --rm php8.3 php ./vendor/bin/phpunit -c tests/phpunit-8.3.xml && \
echo -e "\n\ndone.\n"
26 changes: 12 additions & 14 deletions tests/phpunit-8.1.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- PHPUnit 9 >= PHP 7.3 (https://phpunit.de/supported-versions.html) -->
<!-- PHPUnit 10 >= PHP 8.1 (https://phpunit.de/supported-versions.html) -->
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./../vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
cacheResult ="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
cacheResult="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<testsuites>
<testsuite name="PhpArrayToXml Test Suite">
<directory>./../tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./../src</directory>
</include>
<exclude>
<directory>./../vendor</directory>
<directory>./../tests</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="PhpArrayToXml Test Suite">
<directory>./../tests/</directory>
</testsuite>
</testsuites>
</source>
</phpunit>