-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add paymentWasAlreadyBooked to FailureResponse
Add a new static constructor and a boolean getter to check if the FailureResponse is caused by an already booked payment. This will help upstream code to check against this condition without using hard-coded string messages (that might change). Ticket: https://phabricator.wikimedia.org/T321346
- Loading branch information
Showing
3 changed files
with
36 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,24 @@ | ||
<?php | ||
declare( strict_types=1 ); | ||
|
||
namespace WMDE\Fundraising\PaymentContext\Tests\Unit\UseCases\BookPayment; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use WMDE\Fundraising\PaymentContext\UseCases\BookPayment\FailureResponse; | ||
|
||
/** | ||
* @covers \WMDE\Fundraising\PaymentContext\UseCases\BookPayment\FailureResponse | ||
*/ | ||
class FailureResponseTest extends TestCase { | ||
public function testWhenUsingAlreadyCompletedConstructor_isAlreadyCompletedReturnsTrue(): void { | ||
$response = FailureResponse::newAlreadyCompletedResponse(); | ||
|
||
$this->assertTrue( $response->paymentWasAlreadyCompleted() ); | ||
} | ||
|
||
public function testWhenStringConstructor_isAlreadyCompletedReturnsFalse(): void { | ||
$response = new FailureResponse( 'Could not book payment for ... reasons.' ); | ||
|
||
$this->assertFalse( $response->paymentWasAlreadyCompleted() ); | ||
} | ||
} |