-
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.
Merge pull request #3 from MyParcelCOM/feature/qa-adjustments
✨ Added redirect_url on setup request and PublishJob
- Loading branch information
Showing
3 changed files
with
84 additions
and
2 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
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 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelCom\Payments\Providers\Sns; | ||
|
||
use DateTimeInterface; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class PublishJob implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
public function __construct( | ||
private readonly string $topicArn, | ||
private readonly string $myparcelcomPaymentId, | ||
private readonly ?DateTimeInterface $paidAt = null, | ||
) { | ||
} | ||
|
||
public function handle(Publisher $publisher): void | ||
{ | ||
$publisher | ||
->publish($this->topicArn, $this->myparcelcomPaymentId, $this->paidAt) | ||
->wait(); | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sns; | ||
|
||
use Faker\Factory; | ||
use GuzzleHttp\Promise\Promise; | ||
use Mockery; | ||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; | ||
use Mockery\MockInterface; | ||
use MyParcelCom\Payments\Providers\Sns\Publisher; | ||
use MyParcelCom\Payments\Providers\Sns\PublishJob; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class PublishJobTest extends TestCase | ||
{ | ||
use MockeryPHPUnitIntegration; | ||
|
||
public function test_it_handles_publish_job(): void | ||
{ | ||
$faker = Factory::create(); | ||
$topicArn = "arn:aws:sns:eu-west-1:{$faker->randomNumber()}:{$faker->word}"; | ||
$myparcelcomPaymentId = $faker->uuid; | ||
$paidAt = $faker->dateTime; | ||
|
||
$snsPromise = Mockery::mock(Promise::class, function (MockInterface & Promise $mock) { | ||
$mock->expects('wait'); | ||
}); | ||
|
||
$publisher = Mockery::mock(Publisher::class, function (MockInterface & Publisher $mock) use ( | ||
$snsPromise, | ||
$topicArn, | ||
$myparcelcomPaymentId, | ||
$paidAt | ||
) { | ||
$mock->expects('publish') | ||
->with($topicArn, $myparcelcomPaymentId, $paidAt) | ||
->andReturns($snsPromise); | ||
}); | ||
|
||
$job = new PublishJob($topicArn, $myparcelcomPaymentId, $paidAt); | ||
$job->handle($publisher); | ||
} | ||
} |