Skip to content

Commit 9682f10

Browse files
committed
Add PHPUnit tests for PHP 5.4 to 8.0
1 parent 2f04be3 commit 9682f10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+878
-13
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ Dump as HTML
3737

3838
```php
3939
// get backtrace dump as array
40-
\DebugBacktraceHtml::getBacktraces($offset = 0, $limit = null);
40+
\DebugBacktraceHtml::getBacktraces();
4141
// get backtrace dump as HTML
42-
\DebugBacktraceHtml::getDump($offset = 0, $limit = null);
42+
\DebugBacktraceHtml::getDump();
4343
// write getDump() HTML with echo
44-
\DebugBacktraceHtml::dump($offset = 0, $limit = null);
44+
\DebugBacktraceHtml::dump();
4545
// write getDump() HTML with echo, and exit
46-
\DebugBacktraceHtml::eDump($offset = 0, $limit = null);
46+
\DebugBacktraceHtml::eDump();
4747
```
48-
![HTML backtrace](backtrace_html.png)
48+
![HTML backtrace](resources/backtrace_html.png)
4949

5050
Dump in symfony/console application
5151
-----------------------------------
5252

5353
```php
54-
// write dump in $output
55-
\DebugBacktraceConsole::dump(OutputInterface $output, $offset = 0, $limit = null);
56-
// write dump in $output, and exit
57-
\DebugBacktraceConsole::eDump(OutputInterface $output, $offset = 0, $limit = null);
54+
// Write dump
55+
\DebugBacktraceConsole::dump();
56+
// Write dump and exit
57+
\DebugBacktraceConsole::eDump();
5858
```
59-
![Console backtrace](backtrace_console.jpg)
59+
![Console backtrace](resources/backtrace_console.jpg)

bin/ci/phpunit

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
3+
readonly rootDir="$(realpath $(dirname $(realpath $0))/../..)"
4+
source "${rootDir}/bin/common.inc.sh"
5+
6+
function outputState() {
7+
local rewrite="${1}"
8+
local message="$(stateMessage ${phpunitPhp54State} 'PHP 5.4')"
9+
message="${message}\n$(stateMessage ${phpunitPhp55State} 'PHP 5.5')"
10+
message="${message}\n$(stateMessage ${phpunitPhp56State} 'PHP 5.6')"
11+
message="${message}\n$(stateMessage ${phpunitPhp70State} 'PHP 7.0')"
12+
message="${message}\n$(stateMessage ${phpunitPhp71State} 'PHP 7.1')"
13+
message="${message}\n$(stateMessage ${phpunitPhp72State} 'PHP 7.2')"
14+
message="${message}\n$(stateMessage ${phpunitPhp73State} 'PHP 7.3')"
15+
message="${message}\n$(stateMessage ${phpunitPhp74State} 'PHP 7.4')"
16+
message="${message}\n$(stateMessage ${phpunitPhp80State} 'PHP 8.0')"
17+
18+
if [ ${rewrite} == true ]; then
19+
printf "\e[9A\e[K${message}\n"
20+
else
21+
printf "${message}\n"
22+
fi
23+
}
24+
25+
function stateMessage() {
26+
local state="${1}"
27+
local tool="${2}"
28+
29+
printf "\e[${state}m > \e[0m ${tool}"
30+
}
31+
32+
readonly STATE_RUNNING="45"
33+
readonly STATE_ERROR="41"
34+
readonly STATE_TERMINATED="42"
35+
36+
phpunitPhp54State=${STATE_RUNNING}
37+
phpunitPhp55State=${STATE_RUNNING}
38+
phpunitPhp56State=${STATE_RUNNING}
39+
phpunitPhp70State=${STATE_RUNNING}
40+
phpunitPhp71State=${STATE_RUNNING}
41+
phpunitPhp72State=${STATE_RUNNING}
42+
phpunitPhp73State=${STATE_RUNNING}
43+
phpunitPhp74State=${STATE_RUNNING}
44+
phpunitPhp80State=${STATE_RUNNING}
45+
46+
outputState false
47+
48+
${rootDir}/bin/ci/phpunitPhp54 > /dev/null 2>&1 &
49+
phpunitPhp54ProcessId=$!
50+
51+
${rootDir}/bin/ci/phpunitPhp55 > /dev/null 2>&1 &
52+
phpunitPhp55ProcessId=$!
53+
54+
${rootDir}/bin/ci/phpunitPhp56 > /dev/null 2>&1 &
55+
phpunitPhp56ProcessId=$!
56+
57+
${rootDir}/bin/ci/phpunitPhp70 > /dev/null 2>&1 &
58+
phpunitPhp70ProcessId=$!
59+
60+
${rootDir}/bin/ci/phpunitPhp71 > /dev/null 2>&1 &
61+
phpunitPhp71ProcessId=$!
62+
63+
${rootDir}/bin/ci/phpunitPhp72 > /dev/null 2>&1 &
64+
phpunitPhp72ProcessId=$!
65+
66+
${rootDir}/bin/ci/phpunitPhp73 > /dev/null 2>&1 &
67+
phpunitPhp73ProcessId=$!
68+
69+
${rootDir}/bin/ci/phpunitPhp74 > /dev/null 2>&1 &
70+
phpunitPhp74ProcessId=$!
71+
72+
${rootDir}/bin/ci/phpunitPhp80 > /dev/null 2>&1 &
73+
phpunitPhp80ProcessId=$!
74+
75+
# L'ordre des wait est juste là pour qu'on affiche les flèches en vert le plus tôt possible
76+
# L'idée est de les mettre dans l'ordre de l'outil le plus rapide au plus lent
77+
# bien laisser ";" et pas "&&" pour que les erreurs soient bien trapées
78+
wait "${phpunitPhp54ProcessId}" ; if [ $? == "0" ]; then phpunitPhp54State=${STATE_TERMINATED}; else phpunitPhp54State=${STATE_ERROR}; fi ; outputState true
79+
wait "${phpunitPhp55ProcessId}" ; if [ $? == "0" ]; then phpunitPhp55State=${STATE_TERMINATED}; else phpunitPhp55State=${STATE_ERROR}; fi ; outputState true
80+
wait "${phpunitPhp56ProcessId}" ; if [ $? == "0" ]; then phpunitPhp56State=${STATE_TERMINATED}; else phpunitPhp56State=${STATE_ERROR}; fi ; outputState true
81+
wait "${phpunitPhp70ProcessId}" ; if [ $? == "0" ]; then phpunitPhp70State=${STATE_TERMINATED}; else phpunitPhp70State=${STATE_ERROR}; fi ; outputState true
82+
wait "${phpunitPhp71ProcessId}" ; if [ $? == "0" ]; then phpunitPhp71State=${STATE_TERMINATED}; else phpunitPhp71State=${STATE_ERROR}; fi ; outputState true
83+
wait "${phpunitPhp72ProcessId}" ; if [ $? == "0" ]; then phpunitPhp72State=${STATE_TERMINATED}; else phpunitPhp72State=${STATE_ERROR}; fi ; outputState true
84+
wait "${phpunitPhp73ProcessId}" ; if [ $? == "0" ]; then phpunitPhp73State=${STATE_TERMINATED}; else phpunitPhp73State=${STATE_ERROR}; fi ; outputState true
85+
wait "${phpunitPhp74ProcessId}" ; if [ $? == "0" ]; then phpunitPhp74State=${STATE_TERMINATED}; else phpunitPhp74State=${STATE_ERROR}; fi ; outputState true
86+
wait "${phpunitPhp80ProcessId}" ; if [ $? == "0" ]; then phpunitPhp80State=${STATE_TERMINATED}; else phpunitPhp80State=${STATE_ERROR}; fi ; outputState true

bin/ci/phpunit.inc.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
if [ -z "${PHP_SHORT_VERSION:-}" ]; then
6+
echo "Variable PHP_SHORT_VERSION should be defined."
7+
exit 1
8+
fi
9+
10+
if [ $(which docker || false) ]; then
11+
readonly DOCKER_IMAGE_NAME="steevanb/php-typed-array-ci-php${PHP_SHORT_VERSION}:latest"
12+
13+
if [ -z "${ROOT_DIR:-}" ]; then
14+
echo "Variable ROOT_DIR should be defined."
15+
exit 1
16+
fi
17+
18+
docker \
19+
run \
20+
--rm \
21+
-i \
22+
--volume "${ROOT_DIR}":/app \
23+
"${DOCKER_IMAGE_NAME}" \
24+
"bin/ci/phpunitPhp${PHP_SHORT_VERSION}"
25+
else
26+
# Install steevanb/php-backtrace from current source code
27+
composer global update > /dev/null 2>&1
28+
29+
phpunit tests
30+
fi

bin/ci/phpunitPhp54

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
readonly ROOT_DIR="$(realpath $(dirname $(realpath $0))/../..)"
6+
7+
readonly PHP_SHORT_VERSION="54"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

bin/ci/phpunitPhp55

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
readonly ROOT_DIR="$(realpath $(dirname $(realpath $0))/../..)"
6+
7+
readonly PHP_SHORT_VERSION="55"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

bin/ci/phpunitPhp56

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
readonly ROOT_DIR="$(realpath $(dirname $(realpath $0))/../..)"
6+
7+
readonly PHP_SHORT_VERSION="56"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

bin/ci/phpunitPhp70

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
readonly ROOT_DIR="$(realpath $(dirname $(realpath $0))/../..)"
6+
7+
readonly PHP_SHORT_VERSION="70"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

bin/ci/phpunitPhp71

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
readonly ROOT_DIR="$(realpath $(dirname $(realpath $0))/../..)"
6+
7+
readonly PHP_SHORT_VERSION="71"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

bin/ci/phpunitPhp72

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env sh
2+
3+
set -eu
4+
5+
readonly ROOT_DIR="$(realpath $(dirname $(realpath $0))/../..)"
6+
7+
readonly PHP_SHORT_VERSION="72"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

0 commit comments

Comments
 (0)