Commit Graph

181 Commits

Author SHA1 Message Date
Christopher Allford 027257f624 Changed the dummy postal code in the order helper to a valid one 2019-12-26 13:55:42 +05:30
Rodrigo Primo 62d6b05b58 Fix Generic.Formatting.MultipleStatementAlignment violations
This commit fixes all violations of the Generic.Formatting.MultipleStatementAlignment sniff automatically using phpcbf.
2019-12-20 14:21:08 -03:00
Rodrigo Primo 94373f78ea Fix WordPress.Arrays.MultipleStatementAlignment errors automatically using phpcbf 2019-12-20 13:51:26 -03:00
Claudio Sanches 0686e6f1cd
Merge pull request #25000 from woocommerce/feature/pay-button-support
Initial support for "pay button"
2019-12-04 16:02:02 -03:00
Rodrigo Primo 4af9a94129 PHPCS fixes 2019-12-04 15:52:20 -03:00
Claudio Sanches 15ffaeee6b
Merge pull request #25101 from woocommerce/remove-call_user_func_array
Remove a few calls to func_get_args() and call_user_func_array()
2019-12-03 14:51:43 -03:00
Peter Fabian 309c48ab0e Deprecated old cache function and replaced it with a new one. 2019-11-28 14:03:57 +01:00
Rodrigo Primo 6cd08dc7bd Use the spread operator instead of call_user_func_array() in WC_Data_Store
This commit replaces a call to call_user_func_array() in WC_Data_Store::__call() with argument unpacking using the spread operator which was introduced in PHP 5.6. This change should improve WooCommerce performance a tiny bit since WC_Data_Store::__call() is called somewhat frequently and call_user_func_array() has a bad performance reputation. I added one unit test to make sure this change doesn't break the functionality of the altered method.
2019-11-21 11:52:47 -03:00
Rodrigo Primo fa875a4d25 Fix PHPCS errors in tests/framework/class-wc-dummy-data-store.php 2019-11-21 11:52:07 -03:00
Claudio Sanches ced207633c Added unit tests for pay button support 2019-11-07 17:23:19 -03:00
Peter Fabian e45fe949c1 Added unit test & updated other affected tests. 2019-10-02 14:59:42 +02:00
Rodrigo Primo a8f6a94cda Remove methods assertIsWPError() and assertNotWPError() from WC_Unit_Test_Case
Those two methods are already declared in the class WP_UnitTestCase, so there is
no need to declare them again in the class WC_Unit_Test_Case. The only
caveat is that assertIsWPError() is called assertWPError() in
WP_UnitTestCase so it was necessary to update all of its usages.
2019-07-19 10:56:58 -03:00
Claudio Sanches 67212d1303 Updated PHPUnit to 7.5.14 2019-07-18 22:02:58 -03:00
Claudio Sanches 32996d2fdd Merge branch 'master' into pr/23043 2019-07-09 12:39:40 -03:00
Gerhard 29bb165aca Apply unit tests 2019-07-04 11:50:33 +02:00
Rodrigo Primo 18ee70918b Fix PHPCS violations in tests/ using PHPCBF
This commit fixes all 1533 PHPCS errors that PHPCBF can fix automatically in the tests/ directory. Before this change there was a total of 3106 PHPCS errors in the WooCommerce repository and now there is 1573 errors.
2019-05-01 19:05:00 -03:00
Mike Jolley 20d7603dd6 Merge branch 'fix/21034' 2019-03-12 13:47:08 +00:00
Mike Jolley db6a73d474 Make create_attribute helper use core functions 2019-03-11 14:59:10 +00:00
Mike Jolley d9d458ce07 Clear cache in tests 2019-03-05 18:19:50 +00:00
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