add controllers, servoices

This commit is contained in:
root
2026-03-09 02:52:13 -04:00
parent c8de5f7edc
commit d76c871cb7
501 changed files with 34439 additions and 21843 deletions
@@ -0,0 +1,38 @@
<?php
namespace Tests\Unit\Services\Discounts;
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());
$result = $service->applyVoucher(1, [10], true, 1);
$this->assertFalse($result['ok']);
}
}