<?php


namespace Tests\Services\CacheShelfService;


use App\MaterialBox;
use App\Services\CacheShelfService;
use App\Station;
use Tests\TestCase;

class StationCacheBroadCastTest extends TestCase
{
    /** @var CacheShelfService $service */
    protected $service;
    protected $data = [];

    protected function setUp(): void
    {
        parent::setUp();
        $this->service = app(CacheShelfService::class);
        $this->data['parentStation'] = factory(Station::class)->create();
        $this->data['station']  = factory(Station::class)->create(['parent_id' => $this->data['parentStation']]);
        $this->data['materialBox'] = factory(MaterialBox::class)->create();
        $this->service->createStationTask($this->data['station']['code'],$this->data['materialBox']);
    }

    public function test(){
        // 广播测试
        $this->assertTrue(true);
//        $this->service->_stationCacheBroadCast($this->data['station']['code'],0);
    }

    protected function tearDown(): void
    {
        if($this->data['parentStation'])Station::query()->where('id',$this->data['station']['id'])->delete();
        if($this->data['station'])Station::query()->where('id',$this->data['station']['id'])->delete();
        if($this->data['materialBox'])MaterialBox::query()->where('id',$this->data['materialBox']['id'])->delete();
        parent::tearDown();
    }
}
