-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update payment tests to assert warning levels instead of specific mes…
…sages. Signed-off-by: Sam Poyigi <[email protected]>
- Loading branch information
Showing
4 changed files
with
40 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Igniter\PayRegister\Tests\Models\Observers; | ||
|
||
use Igniter\PayRegister\Models\Observers\PaymentObserver; | ||
use Igniter\PayRegister\Models\Payment; | ||
use Mockery; | ||
|
||
it('applies gateway class and merges data attributes on retrieved', function() { | ||
$payment = Mockery::mock(Payment::class)->makePartial(); | ||
$payment->shouldReceive('extendableGet')->with('data')->andReturn(['key' => 'value']); | ||
$payment->shouldReceive('applyGatewayClass')->once(); | ||
$payment->shouldReceive('getAttributes')->andReturn(['attribute' => 'value']); | ||
$payment->shouldReceive('setRawAttributes')->with(['key' => 'value', 'attribute' => 'value'])->once(); | ||
|
||
$observer = new PaymentObserver(); | ||
$observer->retrieved($payment); | ||
})->only(); | ||
|
||
it('purges config fields on saving if payment exists', function() { | ||
$payment = Mockery::mock(Payment::class)->makePartial(); | ||
$payment->exists = true; | ||
$payment->shouldReceive('purgeConfigFields')->andReturn(['purged' => 'data']); | ||
$payment->shouldReceive('setAttribute')->with('data', ['purged' => 'data'])->once(); | ||
|
||
$observer = new PaymentObserver(); | ||
$observer->saving($payment); | ||
}); | ||
|
||
it('does not purge config fields on saving if payment does not exist', function() { | ||
$payment = Mockery::mock(Payment::class)->makePartial(); | ||
$payment->exists = false; | ||
$payment->shouldNotReceive('purgeConfigFields'); | ||
|
||
$observer = new PaymentObserver(); | ||
$observer->saving($payment); | ||
}); |
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