<?php

namespace Tests\Unit\Services\Inventory;

use App\Services\Inventory\SupplyCategoryService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class SupplyCategoryServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_create_category(): void
    {
        $service = new SupplyCategoryService();
        $result = $service->create(['name' => 'Paper']);

        $this->assertTrue($result['ok']);
        $this->assertDatabaseHas('supply_categories', ['name' => 'Paper']);
    }

    public function test_update_category(): void
    {
        $id = DB::table('supply_categories')->insertGetId([
            'name' => 'Pens',
            'created_at' => now(),
            'updated_at' => now(),
        ]);

        $service = new SupplyCategoryService();
        $result = $service->update($id, ['name' => 'Pens Updated']);

        $this->assertTrue($result['ok']);
        $this->assertDatabaseHas('supply_categories', ['id' => $id, 'name' => 'Pens Updated']);
    }
}
