Skip to content

Commit

Permalink
Unit test for POST Invoice reacts on 422 correctly (#52)
Browse files Browse the repository at this point in the history
* POST invoice reacts on 422

* better name
  • Loading branch information
pkopac authored Aug 9, 2019
1 parent 1612329 commit b32f44b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/Unit/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ class InvoiceTest extends \PHPUnit\Framework\TestCase
]
}';

public function testCreateInvoiceFailsOnValidation()
{
$stream = Psr7\stream_for('{invoices: [{errors: {"plan_id": "doesn\'t exist"}}]}');
$response = new Response(422, ['Content-Type' => 'application/json'], $stream);
$mockClient = new \Http\Mock\Client();
$mockClient->addResponse($response);
$cmClient = new Client(null, $mockClient);

$this->expectException(\ChartMogul\Exceptions\SchemaInvalidException::class);
$restult = ChartMogul\CustomerInvoices::create([
'customer_uuid' => 'some_id',
'invoices' => [['mock' => 'invoice']]
], $cmClient);
}

public function testAllInvoices()
{
$stream = Psr7\stream_for(InvoiceTest::ALL_INVOICE_JSON);
Expand Down

0 comments on commit b32f44b

Please sign in to comment.