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

bin/ci/phpunitPhp73

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="73"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

bin/ci/phpunitPhp74

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="74"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

bin/ci/phpunitPhp80

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="80"
8+
. ${ROOT_DIR}/bin/ci/phpunit.inc.sh

bin/common.inc.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -u
4+
5+
function title() {
6+
local title=${1}
7+
local titleLength=${#1}
8+
9+
echo -en "\n\033[46m\033[1;37m "
10+
for x in $(seq 1 ${titleLength}); do echo -en " "; done;
11+
echo -en "\033[0m\n"
12+
13+
echo -en "\033[46m\033[1;37m ${title} \033[0m\n"
14+
echo -en "\033[46m\033[1;37m "
15+
for x in $(seq 1 ${titleLength}); do echo -en " "; done;
16+
echo -en "\033[0m\n\n"
17+
}

bin/composer

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
readonly rootDir="$(realpath $(dirname $(realpath $0))/..)"
6+
7+
function rmComposerLock() {
8+
if [ -f "${rootDir}/composer.lock" ]; then
9+
rm "${rootDir}/composer.lock"
10+
fi
11+
}
12+
13+
rmComposerLock
14+
15+
docker \
16+
run \
17+
--rm \
18+
--interactive \
19+
--tty \
20+
--volume ${rootDir}:/app \
21+
--user $(id -u):$(id -g) \
22+
--workdir=/app \
23+
composer:2.0.13 \
24+
composer $@
25+
26+
rmComposerLock

bin/docker

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
readonly rootDir="$(realpath $(dirname $(realpath $0))/..)"
6+
source "${rootDir}/bin/common.inc.sh"
7+
8+
function buildDockerImage() {
9+
local localPhpVersion="${1}"
10+
local localDockerImageName="steevanb/php-typed-array-ci-php${localPhpVersion}:latest"
11+
if [ ${refresh} == true ]; then
12+
local localRefreshArguments="--no-cache"
13+
else
14+
local localRefreshArguments=
15+
fi
16+
17+
title "Build Docker image ${localDockerImageName}"
18+
DOCKER_BUILDKIT=1 \
19+
docker \
20+
build \
21+
"${rootDir}/docker/php${localPhpVersion}" \
22+
${localRefreshArguments} \
23+
--tag "${localDockerImageName}"
24+
}
25+
26+
refresh=false
27+
for param in "$@"; do
28+
if [ "${param}" == "--refresh" ]; then
29+
refresh=true
30+
fi
31+
done
32+
33+
buildDockerImage "54"
34+
buildDockerImage "55"
35+
buildDockerImage "56"
36+
buildDockerImage "70"
37+
buildDockerImage "71"
38+
buildDockerImage "72"
39+
buildDockerImage "73"
40+
buildDockerImage "74"
41+
buildDockerImage "80"

changelog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
### [2.1.0](../../compare/2.0.1...2.1.0) (2020-05-15)
22

33
- Set `DebugBacktraceConsole::dump()` and `DebugBacktraceConsole::eDump()` `$output` parameter facultative
4+
- Add PHP 8 compatibility
5+
- Add PHPUnit tests for PHP 5.4 to 8.0
6+
- Move files from root to src (it's not a BC break because you must use this classes with autoload)
47

58
### [2.0.1](../../compare/2.0.0...2.0.1) (2017-03-30)
69

@@ -26,7 +29,7 @@
2629

2730
- Fix (Unknow call) when function is called
2831
- Add preview only when available
29-
- Show \Closure in File::Line column, instead of (Unknow file)::(Uknow line)
32+
- Show \Closure in File::Line column, instead of (Unknow file)::(Unknow line)
3033

3134
### 1.0.0 (2016-08-02)
3235

composer.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@
44
"type": "library",
55
"description": "Nice debug_backtrace() dump, with call and code preview",
66
"autoload": {
7-
"files": ["DebugBacktrace.php", "DebugBacktraceHtml.php", "DebugBacktraceConsole.php"]
7+
"files": ["src/DebugBacktrace.php", "src/DebugBacktraceHtml.php", "src/DebugBacktraceConsole.php"]
8+
},
9+
"autoload-dev": {
10+
"psr-4": {
11+
"Steevanb\\PhpBacktrace\\Tests\\": "tests"
12+
}
813
},
914
"require": {
1015
"php": "^5.4|^7.0|^8.0"
16+
},
17+
"require-dev": {
18+
"phpunit/phpunit": "4.8.*",
19+
"symfony/console": "2.8.*"
20+
},
21+
"config": {
22+
"sort-packages": true
1123
}
1224
}

docker/php54/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM php:5.4.45-cli
2+
3+
COPY --from=composer:2.0.13 /usr/bin/composer /usr/local/bin/composer
4+
COPY composer.json /root/.config/composer/
5+
6+
RUN \
7+
apt update \
8+
&& apt install -y git zip \
9+
# To make composer global update works
10+
&& mkdir /app \
11+
&& composer global update --no-dev \
12+
&& ln -s /root/.config/composer/vendor/bin/phpunit /usr/local/bin/phpunit
13+
14+
WORKDIR /app

0 commit comments

Comments
 (0)