Преглед на файлове

CacheShelfServiceTest
GetChildStationTest 修改

ajun преди 5 години
родител
ревизия
869ae46602
променени са 1 файла, в които са добавени 51 реда и са изтрити 0 реда
  1. 51 0
      tests/Services/CacheShelfService/GetChildStationTest.php

+ 51 - 0
tests/Services/CacheShelfService/GetChildStationTest.php

@@ -0,0 +1,51 @@
+<?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
+    }
+
+
+}