Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Leverage the WooCommerce test framework #26

Merged
merged 58 commits into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
086aa82
Install WooCommerce as a dev dependency via Composer, and ensure its …
stevegrunwell Jan 4, 2018
21ad543
Simplify the test bootstrapping tremendously by using WooCommerce's t…
stevegrunwell Jan 4, 2018
15d11c8
Merge branch 'feature/tests-for-data-store' into fix/woocommerce-test…
stevegrunwell Jan 5, 2018
0dd2906
Add a helper method to retrieve the unmodified contents of a woocomme…
stevegrunwell Jan 5, 2018
8a316a6
For consistency, use wc_custom_order_table()->get_table_name() to ret…
stevegrunwell Jan 5, 2018
f62ce24
When retrieving the date columns from a WC_Order object, explicitly c…
stevegrunwell Jan 5, 2018
8e2b43c
Instead of extending Abstract_WC_Order_Data_Store_CPT directly, exten…
stevegrunwell Jan 5, 2018
b44367a
Now that we're extending WC_Order_Data_Store_CPT, remove any code tha…
stevegrunwell Jan 5, 2018
86700f5
Update the class comment for WC_Order_Data_Store_Custom_Table
stevegrunwell Jan 5, 2018
fbf04b1
Simplify WC_Order_Data_Store_Custom_Table::create(), only setting the…
stevegrunwell Jan 5, 2018
f6089b4
Remove more methods (and related tests) that are directly copied from…
stevegrunwell Jan 5, 2018
58a7140
Update the test-coverage Composer script to only run the 'plugin' tes…
stevegrunwell Jan 5, 2018
22f2fa3
Remove a giant get_order() method which, based on the parent class, h…
stevegrunwell Jan 5, 2018
6af8a5e
Add a test for get_order_id_by_order_key()
stevegrunwell Jan 5, 2018
c918d3f
Add tests around delete() and clean up the method a bit
stevegrunwell Jan 5, 2018
2fde693
Merge branch 'develop' into feature/use-woocommerce-test-tools
stevegrunwell Jan 8, 2018
f7679e8
There's a lot going on here, but the general goal is to replace meta …
stevegrunwell Jan 9, 2018
ce90a8e
Rework some of the non-instance-dependent methods to be static.
stevegrunwell Jan 9, 2018
7b27060
Use a LEFT JOIN instead of a regular JOIN for the custom orders table
stevegrunwell Jan 9, 2018
eae6f27
While using a numeric database column is better for doing math, the c…
stevegrunwell Jan 9, 2018
5a172ba
Ensure the custom table is always installed when running the test suite
stevegrunwell Jan 9, 2018
89418f7
Use the same WHERE clause rewriting for customer queries
stevegrunwell Jan 9, 2018
ed8ca1a
Prevent the test environment from enqueueing email actions
stevegrunwell Jan 9, 2018
b66f767
Extend the data store used for Customers as well, as the stock versio…
stevegrunwell Jan 9, 2018
0511f79
Ensure the woocommerce_orders table is truncated after each test
stevegrunwell Jan 9, 2018
d3dbfc5
The cart_tax and total_tax properties are different within WooCommerc…
stevegrunwell Jan 9, 2018
6866839
WooCommerce saves date_completed and date_paid as Unix timestamps, no…
stevegrunwell Jan 10, 2018
dd1315f
Clean up the DataStoreTest class to remove some leakage on the 'wooco…
stevegrunwell Jan 10, 2018
a713df4
Add two new table columns: billing_index and shipping_index.
stevegrunwell Jan 10, 2018
2a96d54
Rewrite search_orders() to search all of the following:
stevegrunwell Jan 10, 2018
09bcff6
Use the liquidweb/woocommerce fork as the dev dependency.
stevegrunwell Jan 10, 2018
7e8eff7
Ensure get_order_data_from_table() uses the get_table_name() helper
stevegrunwell Jan 10, 2018
dcb685d
WooCommerce *stores* prices_include_tax as a 'yes' or 'no', but the h…
stevegrunwell Jan 11, 2018
e869bc0
Use the WooCommerce helpers for creating dummy products/orders instea…
stevegrunwell Jan 11, 2018
0f2462d
Update the inline comments for the WC_Custom_Order_Table class
stevegrunwell Jan 11, 2018
84bd22c
Clean up the customer data store so it passes coding standards checks.
stevegrunwell Jan 11, 2018
0a0840e
Minor PHP_CodeSniffer-whitespace adjustments
stevegrunwell Jan 11, 2018
0caaf35
Ensure the test suite can run on PHP 5.3.
stevegrunwell Jan 11, 2018
adb7c2e
With https://github.com/woocommerce/woocommerce/pull/18417 merged int…
stevegrunwell Jan 11, 2018
19a3e82
Set the minimum *development* version to PHP 7.0.
stevegrunwell Jan 11, 2018
3773011
Install the same tooling + leverage the WooCommerce PHP_CodeSniffer c…
stevegrunwell Jan 11, 2018
d6df611
Simplify the Travis file, removing older versions of PHP and includin…
stevegrunwell Jan 11, 2018
05269e0
Move the bin/ directory under tests/, since the only script in there …
stevegrunwell Jan 11, 2018
68e58ec
When referencing a file, it helps if you use the right filename
stevegrunwell Jan 11, 2018
9b76148
Remove the defaultTestSuite property from the PHPUnit configuration
stevegrunwell Jan 11, 2018
92b4571
Specify the exact path to PHP_CodeSniffer
stevegrunwell Jan 11, 2018
969d1e7
Permit multisite tests to fail (for now), as there's a bug within the…
stevegrunwell Jan 11, 2018
e2bdc79
Use the allow_failures node within the test matrix
stevegrunwell Jan 11, 2018
e87d78d
Coding standards cleanup:
stevegrunwell Jan 11, 2018
46666dd
Fix inline comments based on PHPCS report
stevegrunwell Jan 11, 2018
cb52023
Whitelist direct database queries in the order data store
stevegrunwell Jan 11, 2018
a4591e5
Restructure the filter_database_queries() function to avoid variable …
stevegrunwell Jan 11, 2018
b7804c8
Whitelist a more complicated SQL query for search_orders()
stevegrunwell Jan 11, 2018
809235a
Remove an empty() call that could cause trouble on PHP < 5.5
stevegrunwell Jan 11, 2018
09f6c17
Merge pull request #28 from liquidweb/fix/extend-order-data-store
bswatson Jan 11, 2018
0686ca8
Merge branch 'develop' into fix/woocommerce-test-suite-errors
stevegrunwell Jan 11, 2018
eba07de
Merge branch 'feature/use-woocommerce-test-tools' into fix/woocommerc…
stevegrunwell Jan 11, 2018
9ac856f
Merge pull request #31 from liquidweb/fix/woocommerce-test-suite-errors
bswatson Jan 12, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/tests/coverage
/vendor
composer.lock
tests/coverage
vendor
55 changes: 20 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: php
sudo: false
dist: trusty

language: php

notifications:
email: false

Expand All @@ -11,48 +10,34 @@ cache:
- $HOME/.composer/cache

matrix:
fast_finish: true
include:
- php: 7.2
env: WP_VERSION=trunk
env: WP_VERSION=trunk WP_MULTISITE=0 RUN_PHPCS=1
- php: 7.2
env: WP_VERSION=trunk WP_MULTISITE=1
- php: 7.1
env: WP_VERSION=latest
env: WP_VERSION=latest WP_MULTISITE=0
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=latest
#- php: 5.6
# env: WP_TRAVISCI=phpcs
- php: 5.3
env: WP_VERSION=latest
dist: precise
env: WP_VERSION=latest WP_MULTISITE=0

# The following WooCommerce core test currently fails in multisite, with or without this
# plugin being active:
#
# WC_Tests_Setup_Functions::test_wizard_in_cart_payment_gateways()
allow_failures:
- php: 7.2
env: WP_VERSION=trunk WP_MULTISITE=1


before_script:
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- |
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
phpenv config-rm xdebug.ini
else
echo "xdebug.ini does not exist"
fi
- |
if [[ ! -z "$WP_VERSION" ]] ; then
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
composer global require "phpunit/phpunit=4.8.*|5.7.*"
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
fi
- bash tests/bin/install-wp-tests.sh woocommerce_test root '' localhost $WP_VERSION
- composer install --prefer-source

script:
- phpunit
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit
WP_MULTISITE=1 phpunit
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs
if [[ ${RUN_PHPCS} == 1 ]]; then
./vendor/bin/phpcs
fi
25 changes: 22 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@
"composer/installers": "^1.4",
"xrstf/composer-php52": "^1.0"
},
"require-dev": {
"php": "^7.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"wimg/php-compatibility": "^8.1",
"woocommerce/woocommerce": "dev-master",
"woocommerce/woocommerce-sniffs": "^0.0.1",
"wp-coding-standards/wpcs": "^0.14"
},
"autoload": {
"classmap": ["includes"]
"classmap": [
"includes"
]
},
"autoload-dev": {
"classmap": ["tests/test-tools"]
"classmap": [
"vendor/woocommerce/woocommerce/tests/framework"
]
},
"scripts": {
"post-install-cmd": [
Expand All @@ -25,7 +37,14 @@
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"test-coverage": [
"phpunit --coverage-html=tests/coverage"
"phpunit --testsuite=plugin --coverage-html=tests/coverage"
]
},
"extra": {
"installer-paths": {
"vendor/{$vendor}/{$name}": [
"woocommerce/woocommerce"
]
}
}
}
Loading