| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace Tests\Services\CacheShelfService;
- use App\MaterialBox;
- use App\Services\CacheShelfService;
- use App\Station;
- use App\StationTask;
- use App\StationType;
- use Faker\Factory;
- use Illuminate\Database\Eloquent\Collection;
- use Tests\TestCase;
- class GetChildStationTest extends TestCase
- {
- /** @var CacheShelfService $service */
- protected $service;
- protected $data = [];
- protected function setup(): void
- {
- parent::setup();
- $this->service = app(CacheShelfService::class);
- $stationType = StationType::query()->firstOrCreate(['name'=> '缓存架']);
- $this->data['parentStation'] = factory(Station::class)->create(['code' => 'test','station_type_id' => $stationType['id']]);
- $this->data['station'] = factory(Station::class)->create(['code'=>'childCode','parent_id'=>$this->data['parentStation']['id'],'station_type_id' => $stationType['id']]);
- $this->data['materialBox'] = factory(MaterialBox::class)->create(['code'=> 'test']);
- $this->data['stationTask'] = factory(StationTask::class)->create(['station_id'=>$this->data['station']['id'],'status'=> '处理中']);
- }
- public function testGetTasks()
- {
- $grids = $this->service->getChildStation($this->data['station']['id']);
- $this->assertTrue($grids ? true : false);
- }
- protected function tearDown(): void
- {
- if($this->data['station'])$this->data['station']->delete();
- if($this->data['parentStation'])$this->data['parentStation']->delete();
- if($this->data['materialBox'])$this->data['materialBox']->delete();
- if($this->data['stationTask'])$this->data['stationTask']->delete();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|