Files
root 304fa6bfd0
API CI/CD / Validate (composer + pint) (push) Successful in 3m5s
API CI/CD / Test (PHPUnit) (push) Failing after 7m12s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
fix test issues
2026-07-06 02:39:13 -04:00

40 lines
1.2 KiB
PHP

<?php
namespace Tests\Unit\Services\Discounts;
use App\Services\ApplicationUrlService;
use App\Services\Discounts\DiscountApplyService;
use App\Services\Discounts\DiscountContextService;
use App\Services\Discounts\DiscountInvoiceService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class DiscountApplyServiceTest extends TestCase
{
use RefreshDatabase;
public function test_apply_voucher_returns_error_when_no_remaining_uses(): void
{
DB::table('configuration')->insert([
['id' => 1, 'config_key' => 'school_year', 'config_value' => '2025-2026'],
['id' => 2, 'config_key' => 'semester', 'config_value' => 'Fall'],
]);
DB::table('discount_vouchers')->insert([
'id' => 1,
'code' => 'USED-OUT',
'discount_type' => 'fixed',
'discount_value' => 10,
'max_uses' => 1,
'times_used' => 1,
'is_active' => 1,
]);
$service = new DiscountApplyService(new DiscountContextService, new DiscountInvoiceService(app(ApplicationUrlService::class)));
$result = $service->applyVoucher(1, [10], true, 1);
$this->assertFalse($result['ok']);
}
}