diff --git a/tests/Stripe/FileUploadTest.php b/tests/Stripe/FileUploadTest.php index 21bb0b568..a4f9a849e 100644 --- a/tests/Stripe/FileUploadTest.php +++ b/tests/Stripe/FileUploadTest.php @@ -6,36 +6,12 @@ class FileUploadTest extends TestCase { const TEST_RESOURCE_ID = 'file_123'; - /** - * @before - */ - public function setUpFixture() - { - // PHP <= 5.5 does not support arrays as class constants, so we set up - // the fixture as an instance variable. - $this->fixture = [ - 'id' => self::TEST_RESOURCE_ID, - 'object' => 'file_upload', - ]; - } - public function testIsListable() { - $this->stubRequest( + $this->expectsRequest( 'get', - '/v1/files', - [], - null, - false, - [ - 'object' => 'list', - 'data' => [$this->fixture], - 'resource_url' => '/v1/files', - ], - 200, - Stripe::$apiUploadBase + '/v1/files' ); - $resources = FileUpload::all(); $this->assertTrue(is_array($resources->data)); $this->assertInstanceOf("Stripe\\FileUpload", $resources->data[0]); @@ -43,15 +19,9 @@ public function testIsListable() public function testIsRetrievable() { - $this->stubRequest( + $this->expectsRequest( 'get', - '/v1/files/' . self::TEST_RESOURCE_ID, - [], - null, - false, - $this->fixture, - 200, - Stripe::$apiUploadBase + '/v1/files/' . self::TEST_RESOURCE_ID ); $resource = FileUpload::retrieve(self::TEST_RESOURCE_ID); $this->assertInstanceOf("Stripe\\FileUpload", $resource); @@ -59,15 +29,12 @@ public function testIsRetrievable() public function testIsCreatableWithFileHandle() { - $this->stubRequest( + $this->expectsRequest( 'post', '/v1/files', null, ['Content-Type: multipart/form-data'], - true, - $this->fixture, - 200, - Stripe::$apiUploadBase + true ); $fp = fopen(dirname(__FILE__) . '/../data/test.png', 'r'); $resource = FileUpload::create([ @@ -84,15 +51,12 @@ public function testIsCreatableWithCurlFile() return; } - $this->stubRequest( + $this->expectsRequest( 'post', '/v1/files', null, ['Content-Type: multipart/form-data'], - true, - $this->fixture, - 200, - Stripe::$apiUploadBase + true ); $curlFile = new \CurlFile(dirname(__FILE__) . '/../data/test.png'); $resource = FileUpload::create([ diff --git a/tests/TestCase.php b/tests/TestCase.php index 840c0ec58..b013003f0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -13,6 +13,9 @@ class TestCase extends \PHPUnit_Framework_TestCase /** @var string original API key */ protected $origApiKey; + /** @var string original upload base URL */ + protected $origApiUploadBase; + /** @var string original client ID */ protected $origClientId; @@ -30,6 +33,7 @@ protected function setUp() // Save original values so that we can restore them after running tests $this->origApiBase = Stripe::$apiBase; $this->origApiKey = Stripe::getApiKey(); + $this->origApiUploadBase = Stripe::$apiUploadBase; $this->origClientId = Stripe::getClientId(); $this->origApiVersion = Stripe::getApiVersion(); $this->origAccountId = Stripe::getAccountId(); @@ -37,6 +41,7 @@ protected function setUp() // Set up host and credentials for stripe-mock Stripe::$apiBase = "http://localhost:" . MOCK_PORT; Stripe::setApiKey("sk_test_123"); + Stripe::$apiUploadBase = "http://localhost:" . MOCK_PORT; Stripe::setClientId("ca_123"); Stripe::setApiVersion(null); Stripe::setAccountId(null); @@ -53,6 +58,7 @@ protected function tearDown() // Restore original values Stripe::$apiBase = $this->origApiBase; Stripe::setApiKey($this->origApiKey); + Stripe::$apiUploadBase = $this->origApiUploadBase; Stripe::setClientId($this->origClientId); Stripe::setApiVersion($this->origApiVersion); Stripe::setAccountId($this->origAccountId);