Skip to content

Commit 1b961a1

Browse files
authored
Update Travis configuration to get linting and unit tests running again (woocommerce#57)
* Declare the need for MySQL when running the Travis build * Stop running tests on PHP 5.6 * Use the version of PHPUnit installed locally by Composer * Use $TMPDIR instead of hardcoding to /tmp * Remove reference to plugin folder name in unit test bootstrap * Clone WooCommerce instead of downloading a release * Require the WooCommerce test bootstrap file from its new location * Only do branch builds on main
1 parent 5a4b0cb commit 1b961a1

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

.travis.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@ sudo: false
44

55
# Test main supported versions of PHP and HHVM against latest WP. 5.2 is min supported version.
66
php:
7-
- 5.6
87
- 7.0
98
- 7.1
109

10+
services:
11+
- mysql
12+
1113
env:
1214
- WP_VERSION=latest WP_MULTISITE=0
1315

1416
before_script:
1517
- export PATH="$HOME/.composer/vendor/bin:$PATH"
1618
- phpenv config-rm xdebug.ini
19+
- composer install
1720
- bash tests/bin/install-phpunit-tests-dependencies.sh wc_apa_test root '' localhost $WP_VERSION
1821

19-
script: phpunit -c phpunit.xml
22+
script: ./vendor/bin/phpunit -c phpunit.xml
23+
24+
branches:
25+
only:
26+
- main

tests/bin/install-phpunit-tests-dependencies.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ DB_PASS=$3
1212
DB_HOST=${4-localhost}
1313
WP_VERSION=${5-latest}
1414

15-
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
16-
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
15+
TMPDIR=${TMPDIR-/tmp}
16+
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
17+
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
18+
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}
1719

1820
download() {
1921
if [ `which curl` ]; then
@@ -60,12 +62,13 @@ install_wp() {
6062
}
6163

6264
install_woocommerce() {
63-
cd $TRAVIS_BUILD_DIR
64-
cd ..
65-
download https://codeload.github.com/woocommerce/woocommerce/tar.gz/3.2.5 woocommerce.tar.gz
66-
mkdir woocommerce
67-
tar --strip-components=1 -zxmf woocommerce.tar.gz -C woocommerce
68-
cd -
65+
cd $TRAVIS_BUILD_DIR
66+
cd ..
67+
68+
git clone --depth=1 --branch 4.3.1 https://github.com/woocommerce/woocommerce.git
69+
cd woocommerce
70+
composer install
71+
cd -
6972
}
7073

7174
install_test_suite() {

tests/phpunit/bootstrap.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22
$_tests_dir = getenv( 'WP_TESTS_DIR' );
33
if ( ! $_tests_dir ) {
4-
$_tests_dir = '/tmp/wordpress-tests-lib';
4+
$_tests_dir = sys_get_temp_dir() . '/wordpress-tests-lib';
55
}
66

77
require_once $_tests_dir . '/includes/functions.php';
88

99
function _manually_load_plugin() {
10-
$plugins_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
11-
require $plugins_dir . '/woocommerce-gateway-amazon-payments-advanced/woocommerce-gateway-amazon-payments-advanced.php';
12-
require $plugins_dir . '/woocommerce/woocommerce.php';
10+
$base_dir = dirname( dirname( dirname( __FILE__ ) ) );
11+
require $base_dir . '/woocommerce-gateway-amazon-payments-advanced.php';
12+
require $base_dir . '/../woocommerce/woocommerce.php';
1313
}
1414
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
1515

@@ -43,4 +43,4 @@ function _manually_load_plugin() {
4343

4444
// Require the WooCommerce tests bootstrap so that we can use WooCommerce's testing resources as well.
4545
$plugins_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
46-
require_once $plugins_dir . '/woocommerce/tests/bootstrap.php';
46+
require_once $plugins_dir . '/woocommerce/tests/legacy/bootstrap.php';

0 commit comments

Comments
 (0)