49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\ClassPreparation;
|
|
|
|
use App\Services\ClassPreparation\ClassPreparationInventoryService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class ClassPreparationInventoryServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_build_availability_uses_max_value(): void
|
|
{
|
|
DB::table('inventory_categories')->insert([
|
|
'id' => 1,
|
|
'type' => 'classroom',
|
|
'name' => 'Small Table',
|
|
]);
|
|
|
|
DB::table('inventory_items')->insert([
|
|
[
|
|
'type' => 'classroom',
|
|
'category_id' => 1,
|
|
'name' => 'Small Table',
|
|
'quantity' => 5,
|
|
'good_qty' => 5,
|
|
'school_year' => '2025-2026',
|
|
'semester' => 'Fall',
|
|
],
|
|
[
|
|
'type' => 'classroom',
|
|
'category_id' => 1,
|
|
'name' => 'Small Table',
|
|
'quantity' => 3,
|
|
'good_qty' => 3,
|
|
'school_year' => '2025-2026',
|
|
'semester' => 'Fall',
|
|
],
|
|
]);
|
|
|
|
$service = new ClassPreparationInventoryService;
|
|
$map = $service->buildAvailability('2025-2026', 'Fall', true, ['Small Table']);
|
|
|
|
$this->assertSame(8, $map['Small Table']);
|
|
}
|
|
}
|