| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Tests\Services\CacheShelfService;
- use App\MaterialBox;
- use App\Services\CacheShelfService;
- use App\Services\ForeignHaiRoboticsService;
- use App\Station;
- use App\StationTaskMaterialBox;
- use App\Traits\TestMockSubServices;
- use Tests\TestCase;
- class LightOffTaskTest extends TestCase
- {
- use TestMockSubServices;
- /** @var CacheShelfService $service */
- protected $service;
- /** @var ForeignHaiRoboticsService $foreignHaiRoboticsService */
- protected $foreignHaiRoboticsService;
- protected $data = [];
- protected function setup(): void
- {
- parent::setup();
- $this->service = $this->subMock([
- 'class' => CacheShelfService::class,
- 'subService' => [
- 'serviceName' => 'foreignHaiRoboticsService',
- 'class' => ForeignHaiRoboticsService::class,
- 'methods'=>[
- 'controlHaiRobot' =>true
- ]
- ]
- ]);
- $row = 2;
- $col = 1;
- $this->data['parentStation'] = factory(Station::class)->create(['code' => 'testParent']);
- $this->data['locCode'] = 'HAI'.$this->data['station']['code'].'-0'.$col.'-0'.$row;
- $this->data['station'] = factory(Station::class)->create(['parent_id'=>$this->data['parentStation']['id'],'code' => $this->data['locCode']]);
- $this->data['materialBox'] = factory(MaterialBox::class)->create(['code'=>'testMaterialBox']);
- $this->data['PTLAction'] = 0;
- }
- public function testLightOffTask()
- {
- $this->service->lightOffTask($this->data['locCode'],$this->data['PTLAction']);
- $task = StationTaskMaterialBox::query()->where('station_id',$this->data['station']['id'])->where('material_box_id',$this->data['materialBox']['id'])->first();
- $this->assertNotEmpty($task);
- $this->assertEquals($task['status'],'处理中');
- }
- protected function tearDown(): void
- {
- Station::query()->whereIn('id',[$this->data['station']['id'],$this->data['parentStation']['id']])->delete();
- MaterialBox::query()->whereIn('id',$this->data['materialBox']['id'])->delete();
- StationTaskMaterialBox::query()->where('station_id',$this->data['station']['id'])->where('material_box_id',$this->data['materialBox'])->delete();
- parent::tearDown();
- }
- }
|