Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php
<?php | <?php | ||||
namespace Tests\Feature\Controller\Reseller; | namespace Tests\Feature\Controller\Reseller; | ||||
use App\Http\Controllers\API\V4\Reseller\PaymentsController; | use App\Http\Controllers\API\V4\Reseller\PaymentsController; | ||||
use App\Payment; | use App\Payment; | ||||
use App\Providers\PaymentProvider; | |||||
use App\Transaction; | use App\Transaction; | ||||
use App\Wallet; | use App\Wallet; | ||||
use App\WalletSetting; | use App\WalletSetting; | ||||
use GuzzleHttp\Psr7\Response; | use GuzzleHttp\Psr7\Response; | ||||
use Illuminate\Support\Facades\Bus; | use Illuminate\Support\Facades\Bus; | ||||
use Tests\TestCase; | use Tests\TestCase; | ||||
use Tests\BrowserAddonTrait; | use Tests\BrowserAddonTrait; | ||||
use Tests\MollieMocksTrait; | use Tests\MollieMocksTrait; | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | public function testMandates(): void | ||||
$this->assertMatchesRegularExpression('|^https://www.mollie.com|', $json['redirectUrl']); | $this->assertMatchesRegularExpression('|^https://www.mollie.com|', $json['redirectUrl']); | ||||
// Assert the proper payment amount has been used | // Assert the proper payment amount has been used | ||||
$payment = Payment::where('id', $json['id'])->first(); | $payment = Payment::where('id', $json['id'])->first(); | ||||
$this->assertSame(2010, $payment->amount); | $this->assertSame(2010, $payment->amount); | ||||
$this->assertSame($wallet->id, $payment->wallet_id); | $this->assertSame($wallet->id, $payment->wallet_id); | ||||
$this->assertSame($reseller->tenant->title . " Auto-Payment Setup", $payment->description); | $this->assertSame($reseller->tenant->title . " Auto-Payment Setup", $payment->description); | ||||
$this->assertSame(PaymentProvider::TYPE_MANDATE, $payment->type); | $this->assertSame(Payment::TYPE_MANDATE, $payment->type); | ||||
// Test fetching the mandate information | // Test fetching the mandate information | ||||
$response = $this->actingAs($reseller)->get("api/v4/payments/mandate"); | $response = $this->actingAs($reseller)->get("api/v4/payments/mandate"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertEquals(20.10, $json['amount']); | $this->assertEquals(20.10, $json['amount']); | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | class PaymentsMollieTest extends TestCase | ||||
* @group mollie | * @group mollie | ||||
*/ | */ | ||||
public function testListingPaymentMethods(): void | public function testListingPaymentMethods(): void | ||||
{ | { | ||||
Bus::fake(); | Bus::fake(); | ||||
$reseller = $this->getTestUser('reseller@' . \config('app.domain')); | $reseller = $this->getTestUser('reseller@' . \config('app.domain')); | ||||
$response = $this->actingAs($reseller)->get('api/v4/payments/methods?type=' . PaymentProvider::TYPE_ONEOFF); | $response = $this->actingAs($reseller)->get('api/v4/payments/methods?type=' . Payment::TYPE_ONEOFF); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$hasCoinbase = !empty(\config('services.coinbase.key')); | $hasCoinbase = !empty(\config('services.coinbase.key')); | ||||
$this->assertCount(3 + intval($hasCoinbase), $json); | $this->assertCount(3 + intval($hasCoinbase), $json); | ||||
$this->assertSame('creditcard', $json[0]['id']); | $this->assertSame('creditcard', $json[0]['id']); | ||||
$this->assertSame('paypal', $json[1]['id']); | $this->assertSame('paypal', $json[1]['id']); | ||||
$this->assertSame('banktransfer', $json[2]['id']); | $this->assertSame('banktransfer', $json[2]['id']); | ||||
$this->assertSame('bitcoin', $json[3]['id']); | $this->assertSame('bitcoin', $json[3]['id']); | ||||
} | } | ||||
} | } |