Skip to content

Commit 7dbaa22

Browse files
authored
Updated the versions matrix to test our code in CI (#1322)
* Updated the versions matrix to test our code in CI Closes #780 The new build mamtrix includes a variety of these versions: WordPress: - 4.4 (earliest supported by WooCommerce 2.6) - 4.5 - 4.6 - 4.7 - 4.8 - `latest` (4.9 at the moment of writing this) WooCommerce: - 2.6.14 (earliest supported by WCS for now) - 3.0.9 - 3.1.3 - 3.2.6 - 3.3.3 (latest) PHP: - 5.2 (earliest we support) - 5.3 - 5.4 - 5.5 - 5.6 - 7.0 - 7.1 - 7.2 (latest) I added a sensible matrix so we don't hog TravisCI resources for no reason. I made sure that these situations are covered: - Earliest PHP version with latest WC and WP versions. - Earliest PHP, WC and WP versions. - Latest PHP versions with earliest WC and WP versions. - Latest PHP, WC and WP versions. - Earliest WC version with latest WP version. - Earliest WP version with latest WC version. If you ask me, that's already overkill, but the new matrix is slightly shorter than before (1 case less), so I think that's OK. Thoughts? No testing instructions, just check that CI passes. * Fixed typo * Next try * Move JS tests to a different container * Fix tar command * Roll back the `install_wc` change, since the "tests" directory is exclude from the Git zipball/tarball, cloning the repo is the only way to get them. * Fixed test on WooCommerce 3.3. The helper `WC_Helper_Product::create_simple_product()` added a default `weight` in the latest WC version, so that was breaking a test that assumed that the product wouldn't have a valid weight set up. * See what PHPUnit versions are installed. * Try installing a previous version of PHPUnit for PHP 7.2 * Manually install an even older version of PHPUnit for PHP 7.2.
1 parent ce9b1a0 commit 7dbaa22

File tree

2 files changed

+25
-57
lines changed

2 files changed

+25
-57
lines changed

.travis.yml

Lines changed: 21 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,45 @@
33
# Tell Travis CI we're using PHP
44
language: php
55

6-
# PHP version used in first build configuration.
7-
php:
8-
- 5.6
9-
10-
# WordPress version used in first build configuration.
11-
env:
12-
- WP_VERSION=latest
13-
14-
# Next we define our matrix of additional build configurations to test against.
15-
# The versions listed above will automatically create our first configuration,
16-
# so it doesn't need to be re-defined below.
17-
18-
# Test WP trunk/master and two latest versions on minimum (5.2).
19-
# Test WP latest two versions (4.4, 4.4) on most popular (5.5, 5.6).
20-
# Test WP latest stable (4.4) on other supported PHP (5.3, 5.4).
21-
# Test WP trunk/master on edge platforms (7.0, hhvm, PHP nightly).
22-
23-
# WP_VERSION specifies the tag to use. The way these tests are configured to run
24-
# requires at least WordPress 3.8. Specify "master" to test against SVN trunk.
25-
6+
# Define our matrix of build configurations to test against.
267
matrix:
278
include:
28-
- php: 5.2
29-
env: WP_VERSION=latest WC_VERSION=2.6.14
30-
sudo: true
31-
dist: precise
329
- php: 5.2
3310
env: WP_VERSION=4.4 WC_VERSION=2.6.14
3411
sudo: true
3512
dist: precise
36-
- php: 5.3
37-
env: WP_VERSION=latest WC_VERSION=2.6.14
13+
- php: 5.2
14+
env: WP_VERSION=latest WC_VERSION=3.3.3
3815
sudo: true
3916
dist: precise
4017
- php: 5.3
41-
env: WP_VERSION=4.4 WC_VERSION=2.6.14
18+
env: WP_VERSION=4.5 WC_VERSION=3.2.6
4219
sudo: true
4320
dist: precise
4421
- php: 5.4
45-
env: WP_VERSION=latest WC_VERSION=2.6.14
46-
- php: 5.4
47-
env: WP_VERSION=4.4 WC_VERSION=2.6.14
22+
env: WP_VERSION=4.6 WC_VERSION=3.1.2
4823
- php: 5.5
24+
env: WP_VERSION=4.7 WC_VERSION=3.0.9
25+
- php: 5.6
26+
env: WP_VERSION=4.8 WC_VERSION=2.6.14
27+
- php: 7.0
4928
env: WP_VERSION=latest WC_VERSION=2.6.14
50-
- php: 5.5
51-
env: WP_VERSION=4.4 WC_VERSION=2.6.14
52-
- php: 5.5
29+
- php: 7.1
5330
env: WP_VERSION=latest WC_VERSION=3.0.3
54-
# 5.6 / master already included above as first build.
55-
- php: 5.6
31+
- php: 7.2
5632
env: WP_VERSION=4.4 WC_VERSION=2.6.14
57-
- php: 5.6
58-
env: WP_VERSION=4.4 WC_VERSION=3.0.3
59-
60-
# Cache the NPM dependencies
61-
cache:
62-
directories:
63-
- node_modules
64-
- "$HOME/.nvm"
65-
66-
# Use an updated Node runtime
67-
# See: http://entulho.fiatjaf.alhur.es/guias/how-to-use-node-along-with-other-language-on-travis-ci/
68-
install:
69-
- . $HOME/.nvm/nvm.sh
70-
- nvm install 8.9.3
71-
- nvm use 8.9.3
72-
- npm install
33+
# Older versions of WP are not compatible with PHPUnit 6+. Manually install PHPUnit 5.
34+
script: curl -sSfL -o ~/.phpenv/versions/7.2/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar && phpunit
35+
- php: 7.2
36+
env: WP_VERSION=latest WC_VERSION=3.3.3
37+
# Not even the latest WP version is compatible with PHPUnit 7. Manually install PHPUnit 6.
38+
script: curl -sSfL -o ~/.phpenv/versions/7.2/bin/phpunit https://phar.phpunit.de/phpunit-6.4.phar && phpunit
39+
# Run the JS tests in a separate container
40+
- language: node_js
41+
before_script: ""
7342

7443
# Clones WordPress and configures our testing environment.
75-
before_script:
76-
- bash tests/bin/install-wc-tests.sh wordpress_test root '' localhost $WP_VERSION $WC_VERSION
77-
78-
script: phpunit && npm test
44+
before_script: bash tests/bin/install-wc-tests.sh wordpress_test root '' localhost $WP_VERSION $WC_VERSION
7945

8046
sudo: false
8147

tests/php/test_class-wc-connect-api-client.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ public function tearDown() {
2727
WC_Helper_Product::delete_product( $this->product->get_id() );
2828
}
2929

30-
public function test_build_shipment_contents_simple_product_no_dimensions() {
30+
public function test_build_shipment_contents_simple_product_no_weight() {
3131
$this->product = WC_Helper_Product::create_simple_product();
32+
$product_id = $this->product->get_id();
33+
update_post_meta( $product_id, '_weight', '' );
3234

33-
WC()->cart->add_to_cart( $this->product->get_id(), 1 );
35+
WC()->cart->add_to_cart( $product_id, 1 );
3436

3537
$actual = $this->api_client->build_shipment_contents( array( 'contents' => WC()->cart->get_cart() ) );
3638

0 commit comments

Comments
 (0)