Skip to content

Commit

Permalink
Add test as well
Browse files Browse the repository at this point in the history
  • Loading branch information
zoranbogoevski committed Nov 17, 2023
1 parent a48110f commit 86c3818
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/tests/Feature/PaymentControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Kalimeromk\HalkbankPayment\tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;

class PaymentControllerTest extends TestCase
{
use RefreshDatabase, WithFaker;

/** @test */
public function it_shows_the_payment_form()
{
$response = $this->get('payment/100');

$response->assertStatus(200);
$response->assertViewIs('payment::payment');
}

/** @test */
public function it_handles_payment_success()
{
$mockData = [
'ReturnOid' => 'test-order-id12345'
];

$response = $this->post('/payment/success', $mockData);

$response->assertStatus(200);
$response->assertViewIs('payment::success');
}

/** @test */
public function it_handles_payment_failure()
{
$mockData = [
'clientIp' => '127.0.0.1',
'mdErrorMsg' => 'Test error message',
'ErrMsg' => 'Test error description'
];

$response = $this->post('/payment/fail', $mockData);

$response->assertStatus(200);
$response->assertViewIs('payment::fail');
}
}

0 comments on commit 86c3818

Please sign in to comment.