This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
generated from a8cteam51/team51-plugin-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
brent
committed
Oct 30, 2024
1 parent
ec68f9b
commit 7bdf96b
Showing
4 changed files
with
159 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php declare( strict_types = 1 ); | ||
|
||
// phpcs:disable | ||
|
||
namespace SiftApi; | ||
|
||
use WPCOMSpecialProjects\SiftDecisions\Sift\SiftObjectValidator; | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
require_once 'SiftObjectValidatorTest.php'; | ||
|
||
class Validate_OrderStatus_Test extends SiftObjectValidatorTest { | ||
protected static ?string $fixture_name = 'order-status.json'; | ||
|
||
protected static function validator( $data ) { | ||
return SiftObjectValidator::validate_order_status( $data ); | ||
} | ||
|
||
public function test_user_id_required() { | ||
static::assert_invalid_argument_exception( | ||
static::modify_data( [ '$user_id' => null ] ), | ||
'missing $user_id' | ||
); | ||
} | ||
|
||
public function test_order_id_required() { | ||
static::assert_invalid_argument_exception( | ||
static::modify_data( [ '$order_id' => null ] ), | ||
'missing $order_id' | ||
); | ||
} | ||
|
||
public function test_order_status_required() { | ||
static::assert_invalid_argument_exception( | ||
static::modify_data( [ '$order_status' => null ] ), | ||
'missing $order_status' | ||
); | ||
} | ||
|
||
public function test_app_browser_set() { | ||
$data = static::load_json(); | ||
static::assert_invalid_argument_exception( | ||
$data, | ||
'Cannot have both $app and $browser' | ||
); | ||
} | ||
|
||
public function test_site_country() { | ||
static::assert_invalid_argument_exception( | ||
static::modify_data( [ '$site_country' => 'US1' ] ), | ||
'$site_country: must be an ISO 3166 country code' | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$user_id" : "billy_jones_301", | ||
"$order_id" : "ORDER-28168441", | ||
"$order_status" : "$canceled", | ||
|
||
"$reason" : "$payment_risk", | ||
"$source" : "$manual_review", | ||
"$analyst" : "[email protected]", | ||
"$webhook_id" : "3ff1082a4aea8d0c58e3643ddb7a5bb87ffffeb2492dca33", | ||
"$description" : "Canceling because multiple fraudulent users on device", | ||
"$ip" : "54.208.214.78", | ||
|
||
|
||
"$browser" : { | ||
"$user_agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", | ||
"$accept_language" : "en-US", | ||
"$content_language" : "en-GB" | ||
}, | ||
|
||
"$app" : { | ||
|
||
"$os" : "iOS", | ||
"$os_version" : "10.1.3", | ||
"$device_manufacturer" : "Apple", | ||
"$device_model" : "iPhone 4,2", | ||
"$device_unique_id" : "A3D261E4-DE0A-470B-9E4A-720F3D3D22E6", | ||
"$app_name" : "Calculator", | ||
"$app_version" : "3.2.7", | ||
"$client_language" : "en-US" | ||
} | ||
} |