Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemd24 committed Sep 12, 2024
1 parent bfea9b0 commit af40ca3
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,50 @@ public function test_delete_shipping_time_country_invalid_query() {
$this->assertEquals( 'error', $e->getMessage() );
}
}

public function test_missing_time_param() {
$payload = [
'country_code' => 'US',
'max_time' => 10,
];

$response = $this->do_request( self::ROUTE_SHIPPING_TIMES, 'POST', $payload );
$this->assertEquals( 400, $response->get_status() );
$this->assertEquals( 'Missing parameter(s): time', $response->get_data()['message'] );
}

public function test_missing_max_time_param() {
$payload = [
'country_code' => 'US',
'time' => 10,
];

$response = $this->do_request( self::ROUTE_SHIPPING_TIMES, 'POST', $payload );
$this->assertEquals( 400, $response->get_status() );
$this->assertEquals( 'Missing parameter(s): max_time', $response->get_data()['message'] );
}

public function test_negative_time_param() {
$payload = [
'country_code' => 'US',
'time' => -1,
'max_time' => 10,
];

$response = $this->do_request( self::ROUTE_SHIPPING_TIMES, 'POST', $payload );
$this->assertEquals( 400, $response->get_status() );
$this->assertEquals( 'Shipping times cannot be negative.', $response->get_data()['data']['params']['time'] );
}

public function test_minimum_shipping_time_bigger_than_max_time_param() {
$payload = [
'country_code' => 'US',
'time' => 20,
'max_time' => 10,
];

$response = $this->do_request( self::ROUTE_SHIPPING_TIMES, 'POST', $payload );
$this->assertEquals( 400, $response->get_status() );
$this->assertEquals( 'The minimum shipping time cannot be greater than the maximum shipping time.', $response->get_data()['data']['params']['time'] );
}
}

0 comments on commit af40ca3

Please sign in to comment.