<?php

namespace Tests\Services\StationTaskService;

use App\Services\StationTaskService;
use App\StationTask;
use Illuminate\Support\Collection;
use Tests\TestCase;

class CreateTest extends TestCase
{
    /** @var StationTaskService $service */
    private $service;
    private $data = [];

    public function setUp(): void
    {
        parent::setUp();
        $this->service = app('StationTaskService');
    }

    public function testCreateSuccess()
    {
        $amountToCreate=3;
        $this->data['stationTask']=$this->service->create($amountToCreate);
        $this->assertEquals(Collection::class,get_class($this->data['stationTask']));
        $this->assertEquals($amountToCreate,$this->data['stationTask']->count());
        $this->assertEquals(StationTask::class,get_class($this->data['stationTask'][0]));
    }


    public function tearDown(): void
    {
        StationTask::query()->whereIn('id',data_get($this->data['stationTask'],'*.id')??[])->delete();
        parent::tearDown();
    }
}
