Commit Graph

162 Commits

Author SHA1 Message Date
JeroenSormani f4775ccd90 Use shipping method instead of property through magic + doc return statements 2019-01-04 12:41:38 +00:00
Frédéric Demarle 620008d46a setUpBeforeClass must always call its parent 2018-09-13 13:35:22 +02:00
Claudio Sanches 61873627a7 Merge branch 'master' into feature/rest-api-v3 2018-09-10 19:16:22 -03: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
claudiulodro 0e67fd6d4d Reset payment gateways between tests 2018-08-27 12:05:13 -07: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
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
Peter Fabian 28cb32e54b PHPCS fixes. 2018-07-09 18:30:10 +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 e769029af6 Make create_attribute function for PHPUNIT more versatile by removing hardcoding. 2018-07-06 16:08:32 +02:00
Peter Fabian 1091eb5feb PHPCS corrections. 2018-07-06 16:01:49 +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 97983a2d45 Fixed missing terms in unit tests.
in teardown method, terms are deleted, so e.g. Uncategorized product_cat was only avaialble if test was run individually, not in the whole batch. Should now be fixed.
2018-06-23 13:50:31 +02:00
Rodrigo Primo b6e73f528b Merge branch 'master' into feature/product-custom-tables-supporting-changes 2018-06-15 14:56:31 -03:00
Mike Jolley 77e887efe9 code standards 2018-06-13 16:55:39 +01:00
Mike Jolley c37f724326 Break up tests/test contents 2018-06-13 11:39:28 +01:00
Jeremy Pry a2d3313b36 Add unit tests around coupon item limit setting
Also updates the `WC_Helper_Coupon` class to make it easier to register custom coupon types during tests.

For #20455
2018-06-08 14:17:39 -04:00
Gerhard Potgieter 0d8f002769 Unset the server variable on teardown to avoid out of memory errors 2018-06-01 14:49:02 +02:00
Rodrigo Primo 597033ca6f Merge branch 'master' into feature/product-custom-tables-supporting-changes 2018-04-24 13:47:22 -03:00
Mike Jolley 5ac7aac369 Improve can_refund_order and add unit tests 2018-04-03 17:09:09 +01:00
Rodrigo Primo bb553c88ae Merge branch 'master' into feature/product-custom-tables-supporting-changes 2018-03-29 12:05:55 -03:00
Rodrigo Primo 5a5a2bc1fb Make unit tests work again with PHP 5.2
This commit fixes WC PHPUnit tests in PHP 5.2 that have been broken since commit e68084d7b8 (diff-b43983ff635e47e2ec510ae07726f0b4R30) was merged. The mentioned commit added a new method to WC_Unit_Test_Case that uses late static binding. The problem is that late static binding is available only since PHP 5.3 and WooCommerce still support PHP 5.2. Running WC tests with PHP 5.2 resulted in the following error:

Parse error: syntax error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /home/travis/build/woocommerce/woocommerce/tests/framework/class-wc-unit-test-case.php on line 40 (see https://travis-ci.org/woocommerce/woocommerce/jobs/350303315#L281)

For now, I'm simply removing the method that used late static binding (WC_Unit_Test_Case::include_dependencies()) and manually loading the required dependencies in the two test classes that relied on it. I'm happy to add WC_Unit_Test_Case::include_dependencies() again if someone can find a way to make it compatible with PHP 5.2. If not, we can revisit this once WC drops support for PHP 5.2.
2018-03-12 16:19:47 -03:00
Rodrigo Primo 273ac18087 Rename class WC_Payment_Token_eCheck to WC_Payment_Token_ECheck
Doing this change to make the class name compatible with WP coding standards.
2018-03-07 14:50:21 -03:00
Mike Jolley 778ccf0606 Update unit test helpers to use CRUD methods 2018-01-18 10:48:26 +00:00
Steve Grunwell be05a55b9d Add missing documentation within the WC_Unit_Test_Case class that was causing CI to fail. 2018-01-15 17:38:13 +00:00
Steve Grunwell e68084d7b8 Add a method by which testcases can load necessary files via include_once.
There are a number of files that are only loaded when another function is called (for example, load a reporting class when displaying a widget). An autoloader would be the ideal way to handle this (both in production and for tests), but until PHP compatibility is sorted out this commit adds an easy fix:

Testcases can now populate the protected, static $includes property with filepaths relative to the project root; when the testcase boots up, these files will automatically be included.
2018-01-12 21:33:20 +00:00
Mike Jolley e9105bd37d Fix tests 2017-12-21 19:00:55 +00:00
Gerhard Potgieter 276bff133f Improve unit test coverage (#18136)
* Test for main WooCommerce class

* Check all class instances created from main class.

* Test all constants

* Test for deprecated hook handler classes as well

* Test template path constant

* Check static class instances

* get_cart_item_quantities test

* get_cart_item_quantities & get_cart_contents_weight tests

* check_cart_items test

* Check_cart_item_stock test

* Cart get_cross_sells test

* Cart get_tax_totals test

* WC_Customer_Download_Data_Store tests
2017-12-14 08:45:00 -02:00
Claudio Sanches c6f8e95b97 Merge branch 'master' into feature/webhook-crud 2017-11-28 15:09:10 -02:00
ragulka 4f2e1ee8d4 Ensure refund is deleted when exception is thrown during wc_create_refund 2017-11-22 17:03:58 +01:00
Claudio Sanches f0b6e3fc33 Test removing fee_lines from order in REST API 2017-11-21 16:07:03 -02:00
Claudio Sanches 368d958be4 Merge branch 'master' into feature/webhook-crud 2017-10-10 16:13:37 -03:00
claudiulodro e83758fe38 Cart fee tests 2017-08-22 13:26:55 -07:00
Claudio Sanches 0ac915d0e9 Removed legacy webhook unit tests 2017-08-17 12:07:15 -03:00
Mike Jolley 06381f28bd Edit items rather than recreate 2017-08-10 11:38:09 +01:00
Mike Jolley c16df62b54 Fix tests and bootstrap 2017-07-28 17:43:08 +01:00
Mike Jolley a042643141 Fix tests 2017-05-30 17:36:16 +01:00
claudiulodro 29fa59a0b7 WC_Object_Query 2017-04-24 11:33:17 -07:00
Claudio Sanches 42ca7bda3d Merge pull request #13989 from woocommerce/fix/product-meta-save_post
Fix saving meta when using `save_post`.
2017-04-06 14:38:16 -03:00
James Collins 285daf466b Correctly calculate order total when adding the product 2017-04-06 18:02:06 +08:00
James Collins 09cbf5f816 Avoid deprecated warning when creating an order in unit tests
Unexpected deprecated notice for Action: woocommerce_order_add_product
2017-04-06 17:11:59 +08:00
Justin Shreve 15bf1da7d5 Call save_meta_data before wp_update_post for data stores that use it, and refresh meta cache after. 2017-04-05 14:39:41 -07:00
Claudio Sanches 8452713225 Fill $wc_product_attributes global in unit tests 2017-03-17 18:04:50 -03:00
Claudio Sanches c8be89915c Fixed double @ 2017-03-15 13:46:02 -03:00
Claudio Sanches 59c2849736 Changed version 2.7 to 3.0 2017-03-15 13:36:53 -03:00
Claudiu Lodromanean 3b8eb75c93 Better handling of nested arrays in apply_changes 2017-03-08 11:51:38 -08:00
Mike Jolley 66914966fb Adjust meta saving code throughout
#12885
2017-01-23 11:30:53 +00:00
Dwain Maralack e8fc25bb00 Unit Tests: Add new parameter to order helper create_order method to allow clients to override the default product. 2017-01-05 11:23:22 +02:00
Mike Jolley 98b79ddf5b Unit test warnings 2017-01-03 12:19:03 +00:00
Mike Jolley 47fbae4d26 Product Visibility Taxonomies (#12527)
* Convert visibility and featured to taxonomy

* Comment

* Add missing tax_queries

* Only check SKU after read.

* Added visibility term for outofstock products to speed those queries up al

* wc_bool_to_string
2016-12-08 10:56:45 +00:00