Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chinleung committed Feb 5, 2021
1 parent 111e587 commit f98ea41
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tests/ChargeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace ChinLeung\Converge\Tests;

use ChinLeung\Converge\Charge;
use ChinLeung\Converge\Client;
use ChinLeung\Converge\ConvergeServiceProvider;
use ChinLeung\Converge\Exceptions\CardException;
use ChinLeung\Converge\Token;
use Illuminate\Support\Facades\Http;
Expand All @@ -18,16 +20,34 @@ class ChargeTest extends TestCase
*/
public function a_charge_failure_will_trigger_a_card_exception(): void
{
$client = new Client('id', 'user', 'pin', true);
config([
'converge.merchant_id' => 'merchant',
'converge.user.id' => 'user',
'converge.user.pin' => 'pin',
'converge.demo' => true,
]);

Http::fake([
$client->getEndpoint() => Http::response(file_get_contents(
resolve(Client::class)->getEndpoint() => Http::response(file_get_contents(
__DIR__.'/fixtures/charge-failed-response.txt'
)),
]);

$this->expectException(CardException::class);

$client->charge(new Token('token'), 100);
Charge::create(Token::make('token'), 100);
}

/**
* Retrieve the service providers of the package.
*
* @param \Illuminate\Foundation\Application $app
* @return array
*/
protected function getPackageProviders($app): array
{
return [
ConvergeServiceProvider::class,
];
}
}

0 comments on commit f98ea41

Please sign in to comment.