| 1 | <?php |
||
| 2 | |||
| 3 | namespace tbclla\RevolutMerchant\Tests; |
||
| 4 | |||
| 5 | use Orchestra\Testbench\TestCase; |
||
| 6 | use tbclla\RevolutMerchant\Client; |
||
| 7 | use tbclla\RevolutMerchant\Resources\Resource; |
||
| 8 | use tbclla\RevolutMerchant\Resources\Webhook; |
||
| 9 | |||
| 10 | class WebhookTest extends TestCase |
||
| 11 | { |
||
| 12 | protected function setUp(): void |
||
| 13 | { |
||
| 14 | parent::setUp(); |
||
| 15 | $this->mockClient = $this->mock(Client::class); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 16 | } |
||
| 17 | |||
| 18 | /** @test */ |
||
| 19 | public function the_client_can_return_a_webhook_resource() |
||
| 20 | { |
||
| 21 | $client = new Client('example_key'); |
||
| 22 | $webhook = $client->webhook(); |
||
| 23 | |||
| 24 | $this->assertInstanceOf(Webhook::class, $webhook); |
||
| 25 | $this->assertInstanceOf(Resource::class, $webhook); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** @test */ |
||
| 29 | public function webhooks_can_be_set() |
||
| 30 | { |
||
| 31 | $url = 'http://test.com/webhook'; |
||
| 32 | |||
| 33 | $this->mockClient->shouldReceive()->post(Webhook::ENDPOINT, [ |
||
| 34 | 'json' => [ |
||
| 35 | 'url' => $url, |
||
| 36 | ] |
||
| 37 | ]); |
||
| 38 | |||
| 39 | $webhook = new Webhook($this->mockClient); |
||
| 40 | $webhook->set($url); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** @test */ |
||
| 44 | public function webhooks_can_be_revoked() |
||
| 45 | { |
||
| 46 | $this->mockClient->shouldReceive()->post(Webhook::ENDPOINT, [ |
||
| 47 | 'json' => [ |
||
| 48 | 'url' => null |
||
| 49 | ] |
||
| 50 | ]); |
||
| 51 | |||
| 52 | $webhook = new Webhook($this->mockClient); |
||
| 53 | $webhook->revoke(); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** @test */ |
||
| 57 | public function webhooks_can_be_retrieved() |
||
| 58 | { |
||
| 59 | $this->mockClient->shouldReceive()->get(Webhook::ENDPOINT); |
||
| 60 | |||
| 61 | $webhook = new Webhook($this->mockClient); |
||
| 62 | $webhook->retrieve(); |
||
| 63 | } |
||
| 64 | } |
||
| 65 |