Skip to content

Commit eb91036

Browse files
authored
Merge pull request wpengine#172 from wpengine/php-52
PHP 5.2 Support & PHP 7.1 and 7.2 Lints
2 parents dc94b71 + d24c5e7 commit eb91036

21 files changed

+434
-504
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
composer.lock
12
vendor/
23
node_modules/

.travis.yml

+84-21
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,102 @@
1+
sudo: false
12
language: php
2-
dist: precise
3-
43
php:
5-
- 5.2
6-
- 5.3
4+
- 5.4
75
- 5.5
86
- 5.6
97
- 7.0
108
- 7.1
11-
9+
- 7.2
1210
env:
13-
- WP_VERSION=latest WP_MULTISITE=0
14-
- WP_VERSION=4.5 WP_MULTISITE=0
15-
11+
- WP_VERSION=latest
12+
- WP_VERSION=4.5
13+
dist: trusty
1614
matrix:
1715
include:
16+
- php: 5.2
17+
env: WP_VERSION=latest
18+
dist: precise
19+
- php: 5.2
20+
env: WP_VERSION=4.5
21+
dist: precise
22+
- php: 5.3
23+
env: WP_VERSION=latest
24+
dist: precise
25+
- php: 5.3
26+
env: WP_VERSION=4.5
27+
dist: precise
1828
- php: 5.6
1929
env: WP_VERSION=latest WP_MULTISITE=1
20-
allow_failures:
21-
- php: 5.2
30+
- php: 5.6
31+
env: WP_VERSION=4.5 WP_MULTISITE=1
32+
- php: 7.0
33+
env: NPM_TESTS=1
2234

2335
before_script:
24-
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install 8
25-
- composer install
26-
- npm install
27-
- bash tests/bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
36+
- |
37+
stable='^[0-9\.]+$'
38+
if [[ "$TRAVIS_PHP_VERSION" =~ $stable ]]; then
39+
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
40+
phpenv config-rm xdebug.ini
41+
fi
42+
fi
43+
- |
44+
if [[ "$NPM_TESTS" == "1" ]]; then
45+
rm -rf ~/.nvm
46+
git clone https://github.com/creationix/nvm.git ~/.nvm
47+
cd ~/.nvm
48+
git checkout `git describe --abbrev=0 --tags`
49+
cd $TRAVIS_BUILD_DIR
50+
source ~/.nvm/nvm.sh
51+
nvm install 8
52+
npm install
53+
fi
2854
- export PATH="$HOME/.composer/vendor/bin:$PATH"
2955
- |
30-
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
31-
composer global require "phpunit/phpunit=5.7.*"
56+
case "$TRAVIS_PHP_VERSION" in
57+
5.6|5.5|5.4|5.3)
58+
composer global require "phpunit/phpunit:^4"
59+
;;
60+
5.2)
61+
;;
62+
*)
63+
composer global require "phpunit/phpunit:^6"
64+
;;
65+
esac
66+
- |
67+
if [[ "$TRAVIS_PHP_VERSION" == "5.2" ]]; then
68+
phpenv global 5.4
69+
composer install
70+
phpenv global "$TRAVIS_PHP_VERSION"
3271
else
33-
composer global require "phpunit/phpunit=4.8.*"
72+
composer install
73+
fi
74+
- |
75+
if [[ "$WP_VERSION" == "latest" ]]; then
76+
curl -s http://api.wordpress.org/core/version-check/1.7/ > /tmp/wp-latest.json
77+
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
78+
WP_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
79+
fi
80+
- |
81+
if [[ "$NPM_TESTS" != "1" ]]; then
82+
PLUGIN_SLUG=$(basename $(pwd))
83+
export WP_DEVELOP_DIR=/tmp/wordpress/
84+
git clone --depth=50 --branch="$WP_VERSION" git://develop.git.wordpress.org/ /tmp/wordpress
85+
cd ..
86+
cp -r "$PLUGIN_SLUG" "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
87+
cd /tmp/wordpress/
88+
cp wp-tests-config-sample.php wp-tests-config.php
89+
sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
90+
sed -i "s/yourusernamehere/travis/" wp-tests-config.php
91+
sed -i "s/yourpasswordhere//" wp-tests-config.php
92+
mysql -e "CREATE DATABASE wordpress_tests;" -uroot
93+
cd "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
94+
phpenv rehash
3495
fi
35-
36-
3796
script:
38-
- phpunit
39-
- npm test
97+
- |
98+
if [[ "$NPM_TESTS" == "1" ]]; then
99+
npm test
100+
else
101+
phpunit
102+
fi

composer.json

+18-9
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,32 @@
77
"email": "[email protected]"
88
}],
99
"require": {
10-
"squizlabs/php_codesniffer": "2.8.*",
11-
"wimg/php-compatibility": "dev-master",
10+
"squizlabs/php_codesniffer": "2.9.*",
11+
"wimg/php-compatibility": "^8",
1212
"simplyadmire/composer-plugins" : "@dev"
1313
},
1414
"require-dev": {
1515
"wp-coding-standards/wpcs": "dev-master",
1616
"neronmoon/scriptsdev": "^0.1.0"
1717
},
18-
"autoload": {
19-
"classmap": ["src/wpephpcompat.php"]
20-
},
2118
"scripts": {
22-
"post-update-cmd": "vendor/bin/phpcs --config-delete installed_paths; rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rp vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility",
23-
"post-install-cmd": "vendor/bin/phpcs --config-delete installed_paths; rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rp vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility"
19+
"post-update-cmd": [
20+
"cd php52; composer update; cd ..",
21+
"vendor/bin/phpcs --config-set installed_paths ../../wimg/php-compatibility"
22+
],
23+
"post-install-cmd": [
24+
"cd php52; composer install; cd ..",
25+
"vendor/bin/phpcs --config-set installed_paths ../../wimg/php-compatibility"
26+
]
2427
},
2528
"scripts-dev": {
26-
"post-update-cmd": "vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/;",
27-
"post-install-cmd": "vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/;"
29+
"post-update-cmd": [
30+
"cd php52; composer update; cd ..",
31+
"vendor/bin/phpcs --config-set installed_paths ../../wimg/php-compatibility,../../wp-coding-standards/wpcs"
32+
],
33+
"post-install-cmd": [
34+
"cd php52; composer install; cd ..",
35+
"vendor/bin/phpcs --config-set installed_paths ../../wimg/php-compatibility,../../wp-coding-standards/wpcs"
36+
]
2837
}
2938
}

0 commit comments

Comments
 (0)