Skip to content

Commit 622f75e

Browse files
Install WP-CLI for tests via composer global require
Doing so makes `utils/make-phar.php` available to the test suite. Because WP-CLI will come with Behat, it's not longer necessary to install via `install-package-tests.sh` or the package's dependencies.
1 parent bce0d4b commit 622f75e

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ cache:
1717

1818
env:
1919
global:
20-
- WP_CLI_BIN_DIR=/tmp/wp-cli-phar
20+
- PATH="$HOME/.composer/vendor/bin:$PATH"
21+
- WP_CLI_BIN_DIR=$HOME/.composer/vendor/bin
2122

2223
matrix:
2324
include:
@@ -32,9 +33,14 @@ matrix:
3233
- php: 5.3
3334
env: WP_VERSION=latest
3435

35-
before_script:
36+
install:
3637
- phpenv config-rm xdebug.ini
37-
- composer validate
38+
- composer global require wp-cli/wp-cli
39+
- composer install --no-dev
3840
- bash bin/install-package-tests.sh
3941

40-
script: ./vendor/bin/behat --format progress --strict
42+
before_script:
43+
- composer validate
44+
45+
script:
46+
- behat --format progress --strict

bin/install-package-tests.sh

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,9 @@
22

33
set -ex
44

5-
WP_CLI_BIN_DIR=${WP_CLI_BIN_DIR-/tmp/wp-cli-phar}
6-
7-
PACKAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../ && pwd )"
8-
9-
download() {
10-
if [ `which curl` ]; then
11-
curl -s "$1" > "$2";
12-
elif [ `which wget` ]; then
13-
wget -nv -O "$2" "$1"
14-
fi
15-
}
16-
17-
install_wp_cli() {
18-
19-
# the Behat test suite will pick up the executable found in $WP_CLI_BIN_DIR
20-
mkdir -p $WP_CLI_BIN_DIR
21-
download https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar $WP_CLI_BIN_DIR/wp
22-
chmod +x $WP_CLI_BIN_DIR/wp
23-
24-
}
25-
26-
download_behat() {
27-
28-
cd $PACKAGE_DIR
29-
composer require --dev behat/behat='~2.5'
30-
31-
}
32-
335
install_db() {
346
mysql -e 'CREATE DATABASE IF NOT EXISTS wp_cli_test;' -uroot
357
mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"localhost" IDENTIFIED BY "password1"' -uroot
368
}
379

38-
install_wp_cli
39-
download_behat
4010
install_db

circle.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ machine:
22
php:
33
version: 5.6.22
44
environment:
5-
WP_CLI_BIN_DIR: /tmp/wp-cli-phar
5+
PATH: "$HOME/.composer/vendor/bin:$PATH"
6+
WP_CLI_BIN_DIR: "$HOME/.composer/vendor/bin"
67

78
dependencies:
89
cache_directories:
@@ -14,13 +15,15 @@ dependencies:
1415
- echo "" > /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
1516
# Increase memory limit
1617
- echo "memory_limit = 512M" > /opt/circleci/php/$(phpenv global)/etc/conf.d/memory.ini
17-
18+
override:
19+
- composer global require wp-cli/wp-cli
20+
- composer install --no-dev
21+
- bash bin/install-package-tests.sh
1822

1923
test:
2024
pre:
2125
- composer validate
22-
- bash bin/install-package-tests.sh
2326
override:
24-
- WP_VERSION=latest ./vendor/bin/behat --format progress --strict
27+
- WP_VERSION=latest behat --format progress --strict
2528
- rm -rf '/tmp/wp-cli-test core-download-cache'
26-
- WP_VERSION=trunk ./vendor/bin/behat --format progress --strict
29+
- WP_VERSION=trunk behat --format progress --strict

0 commit comments

Comments
 (0)