| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace Tests\Services\CacheShelfService;
- use App\MaterialBox;
- use App\Services\CacheShelfService;
- use App\Services\ForeignHaiRoboticsService;
- use App\Services\StationCacheShelfGridService;
- use App\Station;
- use App\StationCacheShelfGrid;
- 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;
- $gridIndex = ($row-1)*3 + (3-$col);
- $this->data['station'] = factory(Station::class)->create();
- $this->data['materialBox'] = factory(MaterialBox::class)->create();
- $this->data['stationCacheShelfGrid'] = factory(StationCacheShelfGrid::class)
- ->create(['station_id' => $this->data['station']['id'],'grid_id'=>$gridIndex,'material_box_id'=>$this->data['materialBox']['id']]);
- $this->data['locCode'] = 'HAI'.$this->data['station']['code'].'-0'.$col.'-0'.$row;
- $this->data['PTLAction'] = 0;
- }
- public function testLightOffTask()
- {
- $this->service->lightOffTask($this->data['locCode'],$this->data['PTLAction']);
- $grid = StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->first();
- $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'],'处理中');
- $this->assertEquals($grid['material_id'],null);
- }
- protected function tearDown(): void
- {
- Station::query()->where('id',$this->data['station']['id'])->delete();
- StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->delete();
- MaterialBox::query()->where('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(); // TODO: Change the autogenerated stub
- }
- }
|