HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //var/www/payments-gateway/tests/PaymentControllerTest.php
<?php

namespace App\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class PaymentControllerTest extends WebTestCase
{
    public function testInitiatePayment(): void
    {
        $client = static::createClient();

        $payload = [
            'order_reference' => 'TEST123456',
            'student_id' => 'STU123',
            'amount' => 1000,
            'redirect_url' => 'https://example.com/return',
            'cancel_url' => 'https://example.com/cancel',
            'student_email' => 'student@example.com'
        ];

        $client->request('POST', '/api/payment/initiate', [], [], [
            'CONTENT_TYPE' => 'application/json'
        ], json_encode($payload));

        $this->assertResponseIsSuccessful();
        $this->assertJson($client->getResponse()->getContent());

        $data = json_decode($client->getResponse()->getContent(), true);
        dump($data['payment_link']);
        $this->assertArrayHasKey('payment_link', $data);
        $this->assertStringStartsWith('http', $data['payment_link']);
    }
}