This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace sanitization functions to enforce string values (#10242)
- Loading branch information
1 parent
b8622b4
commit 0346b5a
Showing
3 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
|
||
/** | ||
* Checkout Controller Tests. | ||
* | ||
* phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_print_r, WooCommerce.Commenting.CommentHooks.MissingHookComment | ||
*/ | ||
class Checkout extends MockeryTestCase { | ||
/** | ||
|
@@ -385,4 +387,50 @@ public function test_checkout_force_create_account() { | |
$customer = get_user_by( 'id', $data['customer_id'] ); | ||
$this->assertEquals( $customer->user_email, '[email protected]' ); | ||
} | ||
|
||
/** | ||
* Test account creation options. | ||
*/ | ||
public function test_checkout_invalid_address_data() { | ||
$request = new \WP_REST_Request( 'POST', '/wc/store/v1/checkout' ); | ||
$request->set_header( 'Nonce', wp_create_nonce( 'wc_store_api' ) ); | ||
$request->set_body_params( | ||
array( | ||
'billing_address' => (object) array( | ||
'first_name' => 'test', | ||
'last_name' => array( | ||
'invalid' => 'invalid_data', | ||
), | ||
'company' => '', | ||
'address_1' => 'test', | ||
'address_2' => '', | ||
'city' => 'test', | ||
'state' => '', | ||
'postcode' => 'cb241ab', | ||
'country' => 'GB', | ||
'phone' => '', | ||
'email' => '[email protected]', | ||
), | ||
'shipping_address' => (object) array( | ||
'first_name' => 'test', | ||
'last_name' => 'test', | ||
'company' => '', | ||
'address_1' => 'test', | ||
'address_2' => '', | ||
'city' => 'test', | ||
'state' => '', | ||
'postcode' => 'cb241ab', | ||
'country' => 'GB', | ||
'phone' => '', | ||
), | ||
'payment_method' => 'bacs', | ||
) | ||
); | ||
|
||
$response = rest_get_server()->dispatch( $request ); | ||
$status = $response->get_status(); | ||
$data = $response->get_data(); | ||
|
||
$this->assertEquals( 400, $status, print_r( $data, true ) ); | ||
} | ||
} |