| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace Tests\Services\CacheShelfService;
- use App\MaterialBox;
- use App\Services\CacheService;
- use App\Services\CacheShelfService;
- use App\Services\StationTaskMaterialBoxService;
- use App\Station;
- use App\StationTask;
- use App\StationTaskMaterialBox;
- use App\StationType;
- use Tests\TestCase;
- class PutStationTaskMaterialBoxProcessTest extends TestCase
- {
- /** @var CacheShelfService $cacheShelfService */
- private $cacheShelfService;
- /** @var StationTaskMaterialBoxService $stationTaskMaterialBoxService */
- private $stationTaskMaterialBoxService;
- private $data =[];
- protected function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->cacheShelfService = app(CacheShelfService::class);
- $this->stationTaskMaterialBoxService = app(StationTaskMaterialBoxService::class);
- $stationType = StationType::query()->firstOrCreate(['name' => '缓存架']);
- $this->data['materialBox'] = factory(MaterialBox::class)->create(['code'=>'testCode']);
- $this->data['parentStation'] = factory(Station::class)->create(['code' => 'TestParent','station_type_id' => $stationType['id']]);
- $this->data['station'] = factory(Station::class)->create(['code' => 'Test','station_type_id' => $stationType['id'],'parent_id'=>$this->data['parentStation']['id']]);
- $this->data['stationTask'] = factory(StationTask::class)->create(['station_id'=>$this->data['station']['id'],'status'=>'处理中']);
- $this->data['takeStationTaskMaterialBox'] = $this->stationTaskMaterialBoxService->createByStationAndMaterialBox($this->data['station'],$this->data['materialBox']);
- $this->data['putStationTaskMaterialBox'] = $this->stationTaskMaterialBoxService->createByStationAndMaterialBox($this->data['station'],$this->data['materialBox']);
- }
- public function testPutStationTaskMaterialBoxProcess()
- {
- $this->data['takeStationTaskMaterialBox']->update(['status' => '处理中']);
- $this->cacheShelfService->putStationTaskMaterialBoxProcess($this->data['putStationTaskMaterialBox']);
- $task = StationTaskMaterialBox::query()->where('id',$this->data['takeStationTaskMaterialBox']['id'])->first();
- $this->assertTrue($task ? true : false);
- $this->assertEquals($task['status'] ?? '' ,'完成');
- }
- public function testPutStationTaskMaterialBoxProcessT()
- {
- $this->cacheShelfService->putStationTaskMaterialBoxProcess($this->data['putStationTaskMaterialBox']);
- $task = StationTaskMaterialBox::query()->where('id',$this->data['takeStationTaskMaterialBox']['id'])->first();
- $this->assertTrue($task ? true : false);
- $this->assertNotEquals($task['status'] ?? '' ,'完成');
- }
- protected function tearDown(): void
- {
- if($this->data['materialBox'])$this->data['materialBox']->delete();
- if($this->data['parentStation'])$this->data['parentStation']->delete();
- if($this->data['station'])$this->data['station']->delete();
- if($this->data['stationTask'])$this->data['stationTask']->delete();
- if($this->data['takeStationTaskMaterialBox'])$this->data['takeStationTaskMaterialBox']->delete();
- if($this->data['putStationTaskMaterialBox'])$this->data['putStationTaskMaterialBox']->delete();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|