Add some unit tests to cover changes in PR 46972 (#47098)

* Add unit tests for 's' search parameter in HPOS queries

* Add changelog

* Fix PHPCS issue
This commit is contained in:
Jorge A. Torres 2024-05-14 16:04:17 +01:00 committed by GitHub
parent 5a8dfac898
commit 089be925d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,5 @@
Significance: patch
Type: tweak
Comment: Only adding a few unit tests to our code to cover the changes in PR 46972.

View File

@ -410,7 +410,7 @@ class OrdersTableQueryTests extends WC_Unit_Test_Case {
public function test_query_s_argument() {
$order1 = new \WC_Order();
$order1->set_billing_first_name( '%ir Woo' );
$order1->set_billing_email( 'test_user@woo.test' );
$order1->set_billing_email( 'test_user+shop@woo.test' );
$order1->save();
$order2 = new \WC_Order();
@ -434,6 +434,22 @@ class OrdersTableQueryTests extends WC_Unit_Test_Case {
$query = new OrdersTableQuery( $query_args );
$this->assertEqualsCanonicalizing( array( $order1->get_id() ), $query->orders );
$query_args['s'] = 'test_user+shop';
$query = new OrdersTableQuery( $query_args );
$this->assertEqualsCanonicalizing( array( $order1->get_id() ), $query->orders );
$query_args['s'] = 'test_user+shop@woo.test';
$query = new OrdersTableQuery( $query_args );
$this->assertEqualsCanonicalizing( array( $order1->get_id() ), $query->orders );
$query_args['s'] = rawurlencode( 'test_user+shop@woo.test' );
$query = new OrdersTableQuery( $query_args );
$this->assertCount( 0, $query->orders );
$query_args['s'] = 'other_user';
$query = new OrdersTableQuery( $query_args );
$this->assertEqualsCanonicalizing( array( $order2->get_id() ), $query->orders );
$query_args['s'] = 'woo.test';
$query = new OrdersTableQuery( $query_args );
$this->assertEqualsCanonicalizing( array( $order1->get_id(), $order2->get_id() ), $query->orders );