Christopher Allford
081f0d9133
Settled on an injection method of `init`
...
1. Since our code style dictates that these be `final` methods, we shouldn't be concerned about overlap.
2. There is precedent for `init` methods as requirements before using class instances.
2020-08-07 14:28:29 -07:00
Claudio Sanches
02cf0dfaed
Merge pull request #27239 from woocommerce/fix/package-tag
...
Fix usage of "package" tag in file headers
2020-08-07 13:37:24 -03:00
Claudio Sanches
17f9883f00
Changed | to \
2020-08-07 13:36:41 -03:00
Néstor Soriano
76cf1e4e93
Merge pull request #27140 from woocommerce/fix/23790
...
Always sanitize coupon code to prevent inconsistent between admins and shop owners
2020-08-07 12:42:02 +02:00
Christopher Allford
154c812fc0
Renamed the `StringUtility` to `StringUtil` to make it easier to work with
2020-08-06 12:35:51 -07:00
Christopher Allford
39376abfd2
Added a requirement that `container_init` methods be marked `final` when registering using reflection
2020-08-05 22:34:00 -07:00
Christopher Allford
ff6e30f1c1
Renamed `set_internal_dependencies` to `container_init`
2020-08-05 22:20:13 -07:00
Christopher Allford
cbbfed4989
Replaced the rest of the constructor injection references
2020-08-05 21:28:06 -07:00
Christopher Allford
8e8698a3f6
Fixed test that used PHPUnit function from newer version
2020-08-05 15:43:08 -07:00
Claudio Sanches
3632714885
Removed package tag from src
2020-08-05 14:23:50 -03:00
Claudio Sanches
a50552af75
Use only WooCommerce as package name
2020-08-05 14:11:20 -03:00
Christopher Allford
d178c7ff01
Replaced constructor injection with method injection
...
Since we need to maintain backwards compatibility for class constructors we should settle on using method injection instead of constructor injection. I've replaced the `Definition` class we're using with one that doesn't support constructor arguments and added a check for auto_arg addition. Note that we don't check for method existence in the extended container. This is because reflection is unnecessarily expensive and we should avoid it if at all possible.
2020-08-04 20:37:28 -07:00
Nestor Soriano
200599f8e0
Add unit tests for the type of the value returned by 'get_available_variations'
2020-08-03 16:30:54 +02:00
Claudio Sanches
1cd84d6446
Merge branch 'master' into fix/23790
2020-07-30 16:46:01 -03:00
Claudio Sanches
3c1132e274
Added unit tests for wc_get_current_admin_url()
2020-07-29 21:02:52 -03:00
Christopher Allford
78bff3b2da
Added the parent's SKU to product searches for variations
...
Since the parent's SKU is used when the variation does not have one, we should fall back when searching for consistency.
2020-07-29 16:53:36 -07:00
Claudio Sanches
de383971eb
Reset all after test
2020-07-27 22:07:46 -03:00
Claudio Sanches
2043954ceb
Fixed class name
2020-07-27 21:53:28 -03:00
Claudio Sanches
0f091406df
Test WC_Cart::show_shipping()
2020-07-27 21:52:33 -03:00
Claudio Sanches
4048d19a39
Added unit tests for coupon code sanitization
2020-07-27 17:44:04 -03:00
Néstor Soriano
8c2412ea7d
Merge pull request #26731 from woocommerce/feature/introduce-dependency-injection
...
Introduce a dependency injection framework
2020-07-24 15:12:16 +02:00
Peter Fabian
03230ecf01
Merge pull request #26642 from woocommerce/fix/26607
...
Limit stock changes for order items to status methods for consistency.
2020-07-24 13:23:53 +02:00
Christopher Allford
811ac747e6
Added callable reflection to `add_with_auto_arguments`
...
This allows the dependencies of the callable function to be automatically resolved out of the container too!
2020-07-24 09:25:12 +02:00
Nestor Soriano
408295720c
Fix LegacyProxy::get_instance_of for classesd having an `instance` method.
...
Pass the arguments as `...$args` instead of `$args`.
Also fix related unit test, and remove unnecessary `is_function`.
2020-07-24 09:25:12 +02:00
Nestor Soriano
bd1e6a5db0
Add the ContainerException class, use it for dependency injection related errors.
2020-07-24 09:25:12 +02:00
Nestor Soriano
65b5cbe692
Improve AbstractServiceProvider::add_with_auto_arguments
...
If a class name is passed as a concrete, check that the class
constructor is public if it exists. If another type of concrete is
passed, check that it's valid (a callback or an object).
Also update the autoloader to check if the class file exists,
otherwise class_exists fails if a namespaced class doesn't exist.
2020-07-24 09:25:11 +02:00
Nestor Soriano
6fd84a0401
Add shortcut methods for the LegacyProxy in the WooCommerce class.
...
The following methods are added and can be invoked using `WC()`,
they just redirect to the same methods in LegacyProxy:
call_function
call_static
get_instance_of
2020-07-24 09:25:11 +02:00
Nestor Soriano
abf53086ca
Remove @throws annotation from some unit tests.
2020-07-24 09:25:11 +02:00
Nestor Soriano
29cf161415
Small changes after review feedback:
...
- Method and class renames.
- Removed unnecessary autoloader registration.
- Add a unit test for classes with non-object type hints
in constructor arguments.
2020-07-24 09:24:06 +02:00
Nestor Soriano
4ec143532c
Adjustments in the LegacyProxy class.
...
- `get_instance_of` accepts now arguments to be passed to the
class constructor if necessary.
- `get_special_instance_of` method removed, instead, now if a method
named `get_instance_of_<lowercased class name>` exists in the class,
it is used to get the instance of the class.
- A couple more unit tests added.
2020-07-24 09:24:06 +02:00
Nestor Soriano
282d1dab86
DependencyManagement code folder moved inside an Internal folder.
2020-07-24 09:24:06 +02:00
Nestor Soriano
044a79d941
Added unit tests for `LegacyProxy` and `MockableLegacyProxy`.
...
Also:
- Added sutoloader for the `tests/tools` directory.
2020-07-24 09:24:04 +02:00
Nestor Soriano
c9154d071c
Add tests for `AbstractServiceProvider` and `ExtendedContainer`.
...
Also:
- Make the methods in `AbstractServiceProvider` protected.
- Add an autoloader for files in the `tests/php/src` directory.
- Fix a bug in the provisional (?) autoloader.
2020-07-24 09:23:05 +02:00
Claudio Sanches
64f4fb85e2
Move variation validation logic to add to cart
2020-07-23 19:10:42 -03:00
Christopher Allford
636327c110
Merge pull request #27043 from woocommerce/fix/unit-test-suite
...
Test Suite & Namespace PHPCS Changes
2020-07-20 08:40:00 -07:00
Claudio Sanches
86311a9903
Merge pull request #27046 from woocommerce/fix/26860
...
[Importer/Exporter] Fixed the value display of "Published" for children of draft variable products
2020-07-16 13:15:31 -03:00
Néstor Soriano
24bd19c517
Merge pull request #27038 from woocommerce/add/26192
...
Add existing meta keys to woocommerce_duplicate_product_exclude_meta filter
2020-07-16 11:02:09 +02:00
Claudio Sanches
156b061602
Added unit tests for importer and exporter
2020-07-15 21:49:26 -03:00
Christopher Allford
b71ddd35f1
Added sniffs to enforce PSR-4 in the `src` and `tests/php/src` directories
2020-07-15 16:09:00 -07:00
Christopher Allford
f72b8db576
Added some exceptions to the PHPCS standards for unit tests
...
The file comments and @throws tags are unnecessary in unit tests.
2020-07-15 14:29:13 -07:00
Christopher Allford
55385f6cec
Moved the orphaned unit test into the correct directory
2020-07-15 14:21:34 -07:00
Christopher Allford
13536bef5b
Corrected the WCInstallTest filename
...
It is in the `includes` test section and should have the same filename as the corresponding class.
2020-07-15 14:20:26 -07:00
Christopher Allford
fdee8dceaf
Moved test to correct directory
2020-07-15 07:08:09 -07:00
vedanshujain
aabf4bfe37
Add unit tests.
2020-07-15 15:27:34 +05:30
vedanshujain
af401a7d80
Add unit test
2020-07-14 23:32:12 +05:30
vedanshujain
6a8f9a4abe
Disabled flaky test
2020-07-01 19:09:50 +05:30
vedanshujain
836d764c67
Add tests
2020-07-01 19:09:07 +05:30
Vedanshu Jain
60ffc7ab99
Merge pull request #26583 from woocommerce/fix/26582
...
Fix regression caused by merging #25092 conflicting with #24828
2020-06-12 15:13:21 +05:30
Claudio Sanches
6afbed0c14
Fixed coding standards
2020-06-01 23:55:17 -03:00
vedanshujain
bbb7600f87
Add unit test for calculation based on rounding pref
2020-05-27 23:55:46 +05:30
vedanshujain
af942a131a
Add test to ensure that verify_base_table also creates table if needed.
2020-05-26 23:46:58 +05:30
vedanshujain
418741a0b2
Add unit test for verify_base_tables function
2020-05-22 18:32:04 +05:30
Christopher Allford
7bf9c31f64
Adjusted the column name normalization to avoid squashing meta key case sensitivity
...
Since we were converting the field to lowercase we ended up inserting meta in all lowercase, regardless of what it was in the CSV file. We should only be using the normalized field name when looking at the default columns, and should instead rely on a case-insensitive regex for the special columns.
One thing to note is that we're still defaulting the $headers array to the normalized field, as we don't want to change what is being passed to the filter for unmapped columns.
2020-05-14 21:20:55 -07:00
Christopher Allford
63ba6f7ee0
Moved the PSR-4 namespaced test directory to the correct folder
...
I know this probably doesn't belong in this PR, but it has been thoroughly discussed and I don't think anyone will mind :)
2020-05-14 21:20:47 -07:00
vedanshujain
27ad4a552e
Rename file and class to resemble PSR4 like convention for consistency.
2020-05-05 19:19:37 +05:30
vedanshujain
f4e169f21e
Moved test specific logic from bootstrap to test file
2020-05-02 00:31:54 +05:30
vedanshujain
13dfb8180f
Add unit test and a sample Woo plugin file
2020-05-01 22:47:08 +05:30
Christopher Allford
04ec11e90b
Added a PSR-4 namespaced tests/php folder for tests written against new code in the src directory
2020-04-28 15:41:04 -07:00