Skip to content

Commit

Permalink
test: add test for invalid date values to sanitize
Browse files Browse the repository at this point in the history
  • Loading branch information
David GABISON committed Jan 23, 2025
1 parent 59bf5c6 commit c98892f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/Unit/Donations/Endpoints/TestListDonations.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,44 @@ public function testShouldReturnListWithSameData()
$this->assertSame($expectedItems, $response->data['items']);
}

/**
* @unreleased
*
* @return void
* @throws Exception
*/
public function testShouldFilterInvalidDateArgument_missingMonthDay()
{
$listDonation = give(ListDonations::class);
$key = 'start';
$value = '2020';

$mockRequest = $this->getMockRequest();
$mockRequest->set_param($key, $value);

$response = $listDonation->validateDate($value, $mockRequest, $key);
$this->assertFalse($response);
}

/**
* @unreleased
*
* @return void
* @throws Exception
*/
public function testShouldFilterInvalidDateArgument_InvalidChar()
{
$listDonation = give(ListDonations::class);
$key = 'start';
$value = '2020-mar-02';

$mockRequest = $this->getMockRequest();
$mockRequest->set_param($key, $value);

$response = $listDonation->validateDate($value, $mockRequest, $key);
$this->assertFalse($response);
}

/**
*
* @since 2.25.0
Expand Down

0 comments on commit c98892f

Please sign in to comment.