-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only use files.stripe.com for file creation requests
- Loading branch information
Showing
9 changed files
with
175 additions
and
97 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Stripe; | ||
|
||
/* | ||
* These tests should really be part of `FileTest`, but because the file creation requests use a | ||
* different host, the tests for these methods need their own setup and teardown methods. | ||
*/ | ||
class FileCreationTest extends TestCase | ||
{ | ||
/** | ||
* @before | ||
*/ | ||
public function setUpUploadBase() | ||
{ | ||
Stripe::$apiUploadBase = Stripe::$apiBase; | ||
Stripe::$apiBase = null; | ||
} | ||
|
||
/** | ||
* @after | ||
*/ | ||
public function tearDownUploadBase() | ||
{ | ||
Stripe::$apiBase = Stripe::$apiUploadBase; | ||
Stripe::$apiUploadBase = 'https://files.stripe.com'; | ||
} | ||
|
||
public function testIsCreatableWithFileHandle() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/files', | ||
null, | ||
['Content-Type: multipart/form-data'], | ||
true, | ||
Stripe::$apiUploadBase | ||
); | ||
$fp = fopen(dirname(__FILE__) . '/../data/test.png', 'r'); | ||
$resource = File::create([ | ||
"purpose" => "dispute_evidence", | ||
"file" => $fp, | ||
]); | ||
$this->assertInstanceOf("Stripe\\File", $resource); | ||
} | ||
|
||
public function testIsCreatableWithCurlFile() | ||
{ | ||
if (!class_exists('\CurlFile', false)) { | ||
// Older PHP versions don't support this | ||
return; | ||
} | ||
|
||
$this->expectsRequest( | ||
'post', | ||
'/v1/files', | ||
null, | ||
['Content-Type: multipart/form-data'], | ||
true, | ||
Stripe::$apiUploadBase | ||
); | ||
$curlFile = new \CurlFile(dirname(__FILE__) . '/../data/test.png'); | ||
$resource = File::create([ | ||
"purpose" => "dispute_evidence", | ||
"file" => $curlFile, | ||
]); | ||
$this->assertInstanceOf("Stripe\\File", $resource); | ||
} | ||
} |
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,69 @@ | ||
<?php | ||
|
||
namespace Stripe; | ||
|
||
/* | ||
* These tests should really be part of `FileUploadTest`, but because the file creation requests | ||
* use a different host, the tests for these methods need their own setup and teardown methods. | ||
*/ | ||
class FileUploadCreationTest extends TestCase | ||
{ | ||
/** | ||
* @before | ||
*/ | ||
public function setUpUploadBase() | ||
{ | ||
Stripe::$apiUploadBase = Stripe::$apiBase; | ||
Stripe::$apiBase = null; | ||
} | ||
|
||
/** | ||
* @after | ||
*/ | ||
public function tearDownUploadBase() | ||
{ | ||
Stripe::$apiBase = Stripe::$apiUploadBase; | ||
Stripe::$apiUploadBase = 'https://files.stripe.com'; | ||
} | ||
|
||
public function testIsCreatableWithFileHandle() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/files', | ||
null, | ||
['Content-Type: multipart/form-data'], | ||
true, | ||
Stripe::$apiUploadBase | ||
); | ||
$fp = fopen(dirname(__FILE__) . '/../data/test.png', 'r'); | ||
$resource = FileUpload::create([ | ||
"purpose" => "dispute_evidence", | ||
"file" => $fp, | ||
]); | ||
$this->assertInstanceOf("Stripe\\FileUpload", $resource); | ||
} | ||
|
||
public function testIsCreatableWithCurlFile() | ||
{ | ||
if (!class_exists('\CurlFile', false)) { | ||
// Older PHP versions don't support this | ||
return; | ||
} | ||
|
||
$this->expectsRequest( | ||
'post', | ||
'/v1/files', | ||
null, | ||
['Content-Type: multipart/form-data'], | ||
true, | ||
Stripe::$apiUploadBase | ||
); | ||
$curlFile = new \CurlFile(dirname(__FILE__) . '/../data/test.png'); | ||
$resource = FileUpload::create([ | ||
"purpose" => "dispute_evidence", | ||
"file" => $curlFile, | ||
]); | ||
$this->assertInstanceOf("Stripe\\FileUpload", $resource); | ||
} | ||
} |
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