Files
ladill-merchant/tests/Feature/SearchTest.php
T
isaaccladandCursor f718b9cfbf Initial Ladill Merchant app with Gitea deploy pipeline.
Shop, menu, and booking storefronts with OIDC SSO, Pay checkout, and merchant.ladill.com deployment workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 23:05:21 +00:00

65 lines
1.8 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\QrSaleOrder;
use App\Models\QrCode;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Tests\TestCase;
class SearchTest extends TestCase
{
use RefreshDatabase;
private function user(): User
{
return User::create(['public_id' => (string) Str::uuid(), 'name' => 'A', 'email' => 'a+'.uniqid().'@x.com']);
}
public function test_user_can_search_payments_by_payer_name(): void
{
$user = $this->user();
$qr = QrCode::query()->create([
'user_id' => $user->id,
'short_code' => 'till01',
'type' => QrCode::TYPE_PAYMENT,
'label' => 'Main till',
'destination_url' => 'https://example.com',
'is_active' => true,
]);
QrSaleOrder::query()->create([
'qr_code_id' => $qr->id,
'user_id' => $user->id,
'reference' => 'pay-'.Str::uuid(),
'amount_minor' => 5000,
'currency' => 'GHS',
'platform_fee_minor' => 250,
'merchant_amount_minor' => 4750,
'payer_name' => 'Ama Mensah',
'status' => QrSaleOrder::STATUS_PAID,
'paid_at' => now(),
]);
$response = $this->actingAs($user)
->getJson(route('merchant.search', ['q' => 'Ama']));
$response->assertOk();
$response->assertJsonPath('results.0.type', 'payment');
$response->assertJsonPath('results.0.title', 'Ama Mensah');
}
public function test_search_page_renders_for_authenticated_user(): void
{
$user = $this->user();
$this->actingAs($user)
->get(route('merchant.search'))
->assertOk()
->assertSee('Find payments', false);
}
}