|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\Stripe\Message; |
| 4 | + |
| 5 | +use Omnipay\Tests\TestCase; |
| 6 | + |
| 7 | +class FetchChargeRequestTest extends TestCase |
| 8 | +{ |
| 9 | + public function setUp() |
| 10 | + { |
| 11 | + $this->request = new FetchChargeRequest($this->getHttpClient(), $this->getHttpRequest()); |
| 12 | + $this->request->setChargeReference('ch_180ZdUCryC0oikg4v4lc4F59D'); |
| 13 | + } |
| 14 | + |
| 15 | + public function testEndpoint() |
| 16 | + { |
| 17 | + $this->assertSame('https://api.stripe.com/v1/charges/ch_180ZdUCryC0oikg4v4lc4F59D', $this->request->getEndpoint()); |
| 18 | + } |
| 19 | + |
| 20 | + public function testSendSuccess() |
| 21 | + { |
| 22 | + $this->setMockHttpResponse('FetchChargeSuccess.txt'); |
| 23 | + $response = $this->request->send(); |
| 24 | + |
| 25 | + $this->assertTrue($response->isSuccessful()); |
| 26 | + $this->assertFalse($response->isRedirect()); |
| 27 | + $this->assertSame('ch_180ZdUCryC0oikg4v4lc4F59D', $response->getChargeReference()); |
| 28 | + $this->assertInternalType('array', $response->getSource()); |
| 29 | + $this->assertNull($response->getMessage()); |
| 30 | + } |
| 31 | + |
| 32 | + public function testSendFailure() |
| 33 | + { |
| 34 | + $this->setMockHttpResponse('FetchChargeFailure.txt'); |
| 35 | + $response = $this->request->send(); |
| 36 | + |
| 37 | + $this->assertFalse($response->isSuccessful()); |
| 38 | + $this->assertFalse($response->isRedirect()); |
| 39 | + $this->assertNull($response->getChargeReference()); |
| 40 | + $this->assertNull($response->getSource()); |
| 41 | + $this->assertSame('No such charge: ch_180ZdUCryC0oikg4v4lc4F59D', $response->getMessage()); |
| 42 | + } |
| 43 | +} |
0 commit comments