-
Notifications
You must be signed in to change notification settings - Fork 1
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 #23 from consilience/issue21
Issue #21 add same fix to abstract collection
- Loading branch information
Showing
3 changed files
with
3,903 additions
and
1 deletion.
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,60 @@ | ||
<?php | ||
|
||
namespace Consilience\Starling\Payments\Response; | ||
|
||
/** | ||
* | ||
*/ | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use GuzzleHttp\Psr7\Response as Psr7Response; | ||
use Money\Formatter\DecimalMoneyFormatter; | ||
use Money\Currencies\ISOCurrencies; | ||
use Money\Money; | ||
use Carbon\Carbon; | ||
|
||
class PaymentDetailsCollectionTest extends TestCase | ||
{ | ||
/** | ||
* Read and return the contents of a test JSON file. | ||
*/ | ||
protected function readDataFile($filename) | ||
{ | ||
$dataJson = file_get_contents(__DIR__ . '/../data/' . $filename); | ||
return $dataJson; | ||
} | ||
|
||
/** | ||
* @return void | ||
* @dataProvider providerFromPSR7 | ||
*/ | ||
public function testFromPSR7($contentType) | ||
{ | ||
$payload = $this->readDataFile('paymentDetailsCollection.json'); | ||
|
||
$paymentDetailsCollectionResponse = new Psr7Response( | ||
200, | ||
[ | ||
'Content-Type' => $contentType, | ||
], | ||
// Squeeze out the white space. | ||
json_encode(json_decode($payload)) | ||
); | ||
|
||
$paymentDetailsCollection = PaymentDetailsCollection::fromResponse( | ||
$paymentDetailsCollectionResponse | ||
); | ||
|
||
$this->assertSame(100, $paymentDetailsCollection->count()); | ||
} | ||
|
||
public function providerFromPSR7() | ||
{ | ||
return [ | ||
['application/json'], | ||
['application/json;'], | ||
['application/json; utf-8'], | ||
[' application/json ; utf-8 '], | ||
]; | ||
} | ||
} |
Oops, something went wrong.