Commit Graph

1377 Commits

Author SHA1 Message Date
Claudio Sanches 518d1f0a00 Updated unit tests 2018-09-10 19:26:37 -03:00
Claudio Sanches 61873627a7 Merge branch 'master' into feature/rest-api-v3 2018-09-10 19:16:22 -03:00
Claudiu Lodromanean ba0a989a38
Merge pull request #21306 from woocommerce/feature/21115
[REST API] Reports totals endpoints
2018-09-10 10:23:56 -07:00
Peter Fabian 252670b616 Merge branch 'feature/rest-api-v3' into save-old-tests
# Conflicts:
#	tests/unit-tests/api/products.php
2018-09-10 16:07:35 +02:00
Peter Fabian f6ca4db90e Updated tests for settings endpoint to reflect changes in v3 REST API. 2018-09-10 15:53:41 +02:00
Peter Fabian ec4000232d Updated tests to reflect changes for variations in v3 REST API. 2018-09-10 15:49:07 +02:00
Peter Fabian b6f229238e Updated payment gateways tests for v3 REST API. 2018-09-10 15:42:46 +02:00
Peter Fabian f68bef3e24 Update customers endpoint tests for v3 REST API. 2018-09-10 14:20:23 +02:00
Claudio Sanches 047ad849b4 Fixed /reports/products/totals unit tests 2018-09-08 23:10:20 -03:00
Claudio Sanches 14a1217218 Load all product types even when empty 2018-09-08 22:45:51 -03:00
Claudio Sanches e154b9d0a6 /reports/reviews/totals unit tests 2018-09-08 22:33:59 -03:00
Claudio Sanches e322f279cd /reports/products/totals unit tests 2018-09-08 22:33:44 -03:00
Claudio Sanches 570d0aa3e5 /reports/orders/totals unit tests 2018-09-08 22:33:30 -03:00
Claudio Sanches 975d855edc /reports/customers/totals unit tests 2018-09-08 22:33:14 -03:00
Claudio Sanches c2b4146db3 /reports/coupons/totals unit tests 2018-09-08 22:32:20 -03:00
Claudiu Lodromanean 0cc137be1e
Merge pull request #20848 from woocommerce/fix/20844
Make wc_get_attachment_image_attributes do what it is suppose to.
2018-09-07 12:08:34 -07:00
claudiulodro 08a76e1eea Add srcset handling 2018-09-07 11:36:03 -07:00
Peter Fabian 028db78960 Updated tests. 2018-09-06 17:41:24 +02:00
Claudio Sanches bf69627cb1 Unit tests 2018-09-03 11:05:17 -03:00
claudiulodro e24aa057ad Revise coupon behavior and add unit tests 2018-08-31 08:35:41 -07:00
Coen Jacobs e737d879e1 Make related unit test variables more readable 2018-08-31 07:47:05 -07:00
Claudiu Lodromanean fd722da88a
Merge pull request #21188 from woocommerce/fix/21156
Updated phone validation and formatting rules.
2018-08-30 09:52:13 -07:00
claudiulodro 20886138aa Add unit test to verify coupon validation changes 2018-08-29 13:28:43 -03:00
Claudiu Lodromanean b80c6d86fc
Merge pull request #21207 from woocommerce/speedup-get-request-url-test
Reduce WC_Tests_Paypal_Gateway_Request::test_request_url() execution time
2018-08-28 13:25:09 -07:00
Rodrigo Primo 8b62d5b06e Reduce WC_Tests_Paypal_Gateway_Request::test_request_url() execution time
This commits reduces the execution time of the test WC_Tests_Paypal_Gateway_Request::test_request_url() from about 30s to about 6s (which is still super slow and even after this change this test is still the slowest in our test suite). This test creates several products that are needed to test different scenarios. To make it run faster, the code was changed to create the WC_Product objects without saving them to the database. Just interacting with the objects is enough to this test and skipping the database makes it run much faster. Other tests might benefit from the same technique.
2018-08-27 19:04:50 -03:00
Rodrigo Primo f830c3e3dc Remove more unnecessary cleanup code from unit tests
See #21150 for more details.
2018-08-27 18:37:33 -03:00
Rodrigo Primo 7b6fcd18b5 Remove unused code 2018-08-27 17:54:55 -03:00
claudiulodro 00e9af285c Fix shipping tests and clean up code 2018-08-27 13:14:32 -07:00
Claudiu Lodromanean 1b405c2c12
Merge pull request #21162 from wackywombaat12/Fix/20987
Fix/20987
2018-08-24 09:51:23 -07:00
Claudiu Lodromanean 0627ef916c
Merge pull request #21165 from woocommerce/fix/21145-2
Added tests for _fields query param for system_status/tools endpoint.
2018-08-24 09:42:29 -07:00
claudiulodro 2466728183 Set up unit tests for v3 api and v2 api 2018-08-24 08:49:37 -07:00
Peter Fabian e2ebf84f65 Updated API version in test to v3. 2018-08-24 17:24:52 +02:00
Peter Fabian b05cfc6b17 Updated API version in test to v3. 2018-08-24 17:22:38 +02:00
Peter Fabian 6f025fbcc4 Updated test comment. 2018-08-24 15:56:10 +02:00
Peter Fabian 897af8d20e Updated phone validation and formatting rules. 2018-08-24 15:43:46 +02:00
Jack Boyle 63b84ef407 Fix Requested Changes
Changed to check if field exists and the field is not blank.
2018-08-24 13:03:09 +10:00
Claudiu Lodromanean 9b222d69c9
Merge pull request #21170 from woocommerce/update/remove-tests-unnecessary-code
Remove unnecessary cleanup code from more unit tests
2018-08-23 14:07:47 -07:00
Claudiu Lodromanean babfacd6bb
Merge pull request #21108 from woocommerce/fix/21025
Set tabindex=1 for notices
2018-08-23 13:11:08 -07:00
Rodrigo Primo 5f6c729107 Remove unnecessary clean up code from unit tests
This commit removes unnecessary clean up code form some unit tests. All database changes done during a test are automatically reverted after the test finishes, so it is not necessary to write code to manually remove them. This change simplifies the test code and make it run a bit faster.
2018-08-23 15:15:17 -03:00
Rodrigo Primo b7507ca8b3 Automatically fix phpcs violations using phpcbf 2018-08-23 15:15:11 -03:00
Peter Fabian cf466aedd8 Added tests for _fields query param for system_status/tools endpoint. 2018-08-23 15:33:58 +02:00
Peter Fabian c4dc7cb0de Added test for _fields for system_status endpoint. 2018-08-23 15:19:04 +02:00
Jack Boyle fd33f2c2a6 Added Tests
Added Tests for new wildcard functionality.
2018-08-23 15:23:35 +10:00
Peter Fabian dde3c9fa7b Fixed unit tests. 2018-08-22 10:12:32 +02:00
Rodrigo Primo aa8c0c7629 Remove unnecessary cleanup code from cart test
This commit removes a bunch of unnecessary cleanup code from cart tests. All database changes are automatically reverted after each test, so it is not necessary to write code inside the test to manually revert the changes that were made. One test method was split into three different methods for clarity and to avoid having to revert database changes manually between each part of the test.

This change makes the tests easier to read but also reduced the execution time of the cart tests in about 15%.
2018-08-21 11:41:31 -03:00
Peter Fabian e8956953ba Updated test. 2018-08-09 12:22:26 +02:00
Claudiu Lodromanean 11911aa2ea
Merge pull request #20870 from woocommerce/add/export-products-based-on-category
Add category filter to product export functionality.
2018-08-08 08:51:58 -07:00
Gerhard Potgieter 136f7689eb Update unit test for product exporter category to be array. 2018-08-07 17:44:27 +02:00
Claudiu Lodromanean d32a675c25
Merge pull request #20931 from woocommerce/fix/download-log-data-store
Fix: orderby and order parameters in WC_Customer_Download_Log_Data_Store::get_download_logs()
2018-08-04 07:57:17 -07:00
Claudio Sanches 355eba85ca Updated unit tests 2018-07-31 13:46:59 -03:00
Claudio Sanches 7416be5644 Updated unit test class name 2018-07-31 13:36:31 -03:00
Claudio Sanches ab2514bfd4 Updated unit tests for reviews 2018-07-31 13:33:51 -03:00
Rodrigo Primo b09bb3eee9 Fix: orderby and order parameters in WC_Customer_Download_Log_Data_Store::get_download_logs()
This commit fixes a bug in WC_Customer_Download_Log_Data_Store::get_download_logs() that made impossible to change the order in which the query returned the results. This method accepts the arguments order_by and order, but it was ignoring them and always using the default values ('download_log_id' and 'ASC' respectively).

It also introduces a very basic unit test to cover the method main functionality and to make sure that the parameters order and orderby are not ignored anymore.

It seems that the modified method was inspired in WC_Customer_Download_Data_Store::get_downloads() before the same bug was fixed in #18620.
2018-07-30 16:40:21 -03:00
Peter Fabian 4e7bc117e4 Update unit tests. 2018-07-26 15:11:24 +02:00
Gerhard Potgieter 73b80c9241 Remove extra asterisk 2018-07-25 14:09:04 +02:00
Gerhard Potgieter 5a0d3c8bf7 Fix indentation issues caused by github conflict tool 2018-07-25 14:07:57 +02:00
Gerhard Potgieter da82639ebc
Merge branch 'master' into update/core-function-unit-tests 2018-07-25 14:05:12 +02:00
Claudiu Lodromanean 9e3da78c73
Merge pull request #20853 from woocommerce/reduce-test-suite-execution-time
Reduce WC_Tests_REST_System_Status tests execution time
2018-07-24 10:46:26 -07:00
Claudiu Lodromanean a0b4a8df03
Merge pull request #20611 from woocommerce/fix/20349
Allow filtering variations by attributes in API.
2018-07-24 10:25:36 -07:00
Gerhard Potgieter 7143b67189 Include setting category to product export test 2018-07-23 12:26:58 +02:00
Gerhard Potgieter 8aba169654 Switch travis codecoverage from xdebug to phpdbg (#20857)
This commit changes the travis codecoverage from using xdebug to phpdbg, phpdbg seems much faster and gives similar results.

Reason for switching is we have been running into constant timeouts on our codecoverage due to the 50min job limit on travis, which means our codecoverage has not been updated in a couple of months.

* Remove xdebug as it slows tests down, switch to using phpdbg for code coverage.

* Update parameters for phpdbg

* It is qrr not qqr

* Include vendor/bin path when using phpdbg

* Use PHP 7.1 to run phpdbg

* Update phpunit dire

* Include $HOME in phpdbg call to phpunit

* Set no memory limit to avoid out of memory errors.

* Assign timeout group to test_request_url test for paypal and do not execute that on coverage as it causes a memeory timeout. Test needs optimization to run for code coverage.

* @covers usage for methods should be prefixed with ::
2018-07-20 09:34:43 -03:00
Rodrigo Primo f47c9e7842 Reduce WC_Tests_REST_System_Status tests execution time
This commit changes WC_Tests_REST_System_Status tests to use artificial HTTP responses instead of performing external HTTP requests. With this change execution time for these tests droped from 22s to 3s.
2018-07-19 14:22:29 -03:00
Rodrigo Primo 1860cd1933 Change WC_Unit_Test_Case to extend WP_HTTP_TestCase instead of WP_UnitTestCase
This commits changes WC_Unit_Test_Case parent class to WP_HTTP_TestCase (which extends WP_UnitTestCase). This way all WC core test classes can benefit from the functionality provided by WP_HTTP_TestCase if needed. This is necessary because otherwise test classes can use the functionality provided by WC_Unit_Test_Case or WP_HTTP_TestCase. This change should not affect test classes that don't explicitly call one of the WP_HTTP_TestCase features.
2018-07-19 14:17:06 -03:00
Rodrigo Primo 1d13dd4dd4 Use an artificial HTTP response for wc_do_oembeds() test
Doing this to speed up the test as an HTTP request to an external server is slow and also because it should fix this test that has been failing on Travis only for an unknown reason.
2018-07-19 10:35:32 -03:00
Rodrigo Primo fb9aa71b33 Undoing DB changes on tearDown() is not necessary
WP test suite starts a transaction when the test starts and roll it back when the test finishes. So it is not necessary to undo database changes using tearDown().
2018-07-19 10:35:19 -03:00
Gerhard Potgieter 847d5b680d Add unit test for test_wc_get_attachment_image_attributes 2018-07-19 12:04:36 +02:00
Rodrigo Primo 0e785d4614 Make WC_Tests_Product_CSV_Importer::test_import() faster
This commit changes the WC_Tests_Product_CSV_Importer class to use artificial HTTP responses instead of performing real HTTP requests to a external server to get the images of the imported products. On my local machine, this change reduced the test execution time from 3257ms to 831ms.

As a consequence of this change, this commit also fixes WC_Tests_Product_CSV_Importer::test_import() in all Travis builds. This test has been failing for a few weeks on Travis but not on our local environments. After some debugging, I found out that the test was failing on Travis because of the following error when `wp_safe_remote_get()` was called to get images for the imported products:

```
Error getting remote image http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_front.jpg. Error: cURL error 35: gnutls_handshake() failed: Handshake failed.
```

Apparently, the PHP binary that is used by Travis is unable to handle the TLS handshake (see https://github.com/travis-ci/travis-ci/issues/6339) and the test probably started failing when demo.woothemes.com (which is used to download the images for the imported products) switched from HTTP to HTTPS.
2018-07-18 17:16:26 -03:00
Gerhard Potgieter 1f46caaa4c Test some edge cases where CC name could be empty or contain a non standard value. 2018-07-16 13:02:24 +02:00
Gerhard Potgieter 370c200076 Make wc_array_cartesian test use predefined array for testing against instead of relying on product attributes. 2018-07-16 12:59:01 +02:00
Gerhard Potgieter 9e495478f4 Add unit test for wc_decimal_to_fraction 2018-07-11 15:17:00 +02:00
Gerhard Potgieter a28253739f Add wc_get_permalink_structure unit test 2018-07-11 15:10:55 +02:00
Gerhard Potgieter 0c01b6c3bb Add wc_get_credit_card_type_label unit test 2018-07-11 15:05:18 +02:00
Gerhard Potgieter 1d5605c9dc Add wc_array_cartesian unit test 2018-07-11 14:59:05 +02:00
Gerhard Potgieter 2f7e42bb2f Add wc_get_theme_support unit test 2018-07-11 14:38:33 +02:00
Gerhard Potgieter eb533d0263 Update test_get_woocommerce_currencies to test for both cached and uncached currencies, gives us more code coverage 2018-07-11 14:25:42 +02:00
Gerhard Potgieter a6e7ae15f9 Add unit test for testing wc_get_user_agent 2018-07-11 14:11:31 +02:00
Peter Fabian 7443a2f906 Switched variation creation to CRUD methods for unit test. 2018-07-09 18:27:56 +02:00
Peter Fabian 3af9c1e95b Merge branch 'master' into fix/20349
# Conflicts:
#	tests/framework/helpers/class-wc-helper-product.php
#	tests/unit-tests/api/products.php
2018-07-09 18:18:06 +02:00
Peter Fabian 4a42e2a7fc Added unit tests for query params for variations REST API endpoint. 2018-07-09 17:12:23 +02:00
Peter Fabian 55d7ea4ac5 Improved unit tests for products REST API endpoint. 2018-07-09 17:11:50 +02:00
Gerhard Potgieter bc3c780b92 PHPCS fixes 2018-07-09 13:04:16 +02:00
Gerhard Potgieter 1fdcf2a238 Fix log file deletion functionality. 2018-07-09 13:01:23 +02:00
Peter Fabian 6c70064a82 Added test products API for product tag and attributes query parameters. 2018-07-06 16:57:40 +02:00
Peter Fabian fe77b9e54f Fixed the variation product helper in unit tests.
Previously, the variable product had 2 variations, but one of them had a term assigned ('large') that wasn't assigned to the parent product. Normally, when variable product is created, parent has all the terms assigned to its children assigned.
2018-07-06 16:00:59 +02:00
Peter Fabian 9c420125a3 Added tests for API query parameters for products endpoint. 2018-07-06 12:58:57 +02:00
Claudiu Lodromanean 2a3cedddcd
Merge pull request #20520 from woocommerce/feature/product-custom-tables-supporting-changes
Product custom tables supporting changes
2018-06-27 08:57:50 -07:00
Gerhard Potgieter 2df62edec1 Improve the replacement for wc_format_phone_number a bit more, seems like we allow spaces and plus signs, remove non visible unicode with seperate preg_replace 2018-06-27 09:37:44 +02:00
Peter Fabian 8fd4777fb4 Fixed PHPCS whitespace. 2018-06-25 10:57:52 +02:00
Peter Fabian 6ba409b772 Added category related unit tests for products API. 2018-06-23 13:54:36 +02:00
Rodrigo Primo b6e73f528b Merge branch 'master' into feature/product-custom-tables-supporting-changes 2018-06-15 14:56:31 -03:00
Claudiu Lodromanean c203ff16d9
Merge pull request #20482 from woocommerce/fix/20452
Avoid price setting when synced with children
2018-06-15 09:05:13 -07:00
Mike Jolley 9a550c4a35 Update to correct type in unit test 2018-06-14 16:34:36 +01:00
Claudiu Lodromanean 73dbec001a
Merge pull request #20456 from JPry/custom_coupon_item_limit
Custom coupon item limit
2018-06-13 09:57:47 -07:00
Mike Jolley 31058ac215 Tests -> CRUD 2018-06-13 16:30:42 +01:00
Gerhard Potgieter ab769eb8a7 Update test_save_default_attributes to make use of propper attributes before checking defaults 2018-06-13 15:49:38 +02:00
Mike Jolley 812586742b Allow only valid default attributes 2018-06-13 14:33:13 +01:00
Mike Jolley 9ec7eba0f6 update image URLs 2018-06-13 11:53:30 +01:00
Mike Jolley c37f724326 Break up tests/test contents 2018-06-13 11:39:28 +01:00
Mike Jolley 01a3e359c3 Merge branch 'master' into feature/product-custom-tables-supporting-changes 2018-06-13 10:18:38 +01:00
Gerhard Potgieter 3b9d403b02 Add geolocation::get_ip_address tests 2018-06-11 11:10:11 +02:00