| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace Tests\Services\CacheShelfService;
- use App\MaterialBox;
- use App\Services\CacheShelfService;
- use App\Services\ForeignHaiRoboticsService;
- use App\Services\StationCacheShelfGridService;
- use App\Services\StationTaskMaterialBoxService;
- use App\Station;
- use App\StationCacheShelfGrid;
- use App\StationTaskMaterialBox;
- use App\Traits\TestMockSubServices;
- use Tests\TestCase;
- class PutBinToStoreTest extends TestCase
- {
- use TestMockSubServices;
- /** @var CacheShelfService $cacheShelfService */
- protected $cacheShelfService;
- protected $data =[];
- protected function setup(): void
- {
- parent::setup(); // todo: change the autogenerated stub
- $this->data['station'] = factory(Station::class)->create(['name' => 'test', 'code'=> 'test']);
- $this->data['materialBox'] = factory(MaterialBox::class)->create();
- $this->data['stationTaskMaterialBox'] = factory(StationTaskMaterialBox::class)->create([
- 'station_id' => $this->data['station']['id'],
- 'material_box_id' => $this->data['materialBox']['id'],
- 'status' => 1
- ]);
- $this->data['stationCacheShelfGrid'] = factory(StationCacheShelfGrid::class)->create([
- 'station_id'=>$this->data['station']['id'],
- 'material_box_id'=>$this->data['materialBox']['id'],
- 'status' => 1
- ]);
- $this->cacheShelfService = $this->subMock([
- 'class' => CacheShelfService::class,
- 'subService' => [
- // [
- // 'serviceName' => 'stationTaskMaterialBoxService',
- // 'class' => StationTaskMaterialBoxService::class,
- // 'methods' => [
- // 'createByStationMaterialBox' => $this->data['stationTaskMaterialBox']
- // ]
- // ],
- [
- 'serviceName' => 'stationCacheShelfGridService',
- 'class' => StationCacheShelfGridService::class,
- 'methods' => [
- 'processGrid' => null
- ]
- ],
- [
- 'serviceName' => 'foreignHaiRoboticsService',
- 'class' => ForeignHaiRoboticsService::class,
- 'methods' => [
- // 'putBinToStore_fromCacheShelf' => true,
- 'controlHaiRobot' => true
- ]
- ]
- ]
- ]);
- }
- public function testPutBinToStore()
- {
- $bool = $this->cacheShelfService->putBinToStore($this->data['station'],$this->data['materialBox'],$this->data['stationCacheShelfGrid']);
- $boxTask = StationTaskMaterialBox::query()->where('station_id',$this->data['station']['id'])->where('material_box_id',$this->data['materialBox']['id'])->first();
- $this->assertTrue($bool);
- $this->assertNotEmpty($boxTask);
- $this->assertEquals($boxTask['status'],'待处理');
- }
- protected function tearDown(): void
- {
- Station::query()->where('id',$this->data['station']['id'])->delete();
- MaterialBox::query()->where('id',$this->data['materialBox']['id'])->delete();
- StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->delete();
- StationTaskMaterialBox::query()->where('id',$this->data['stationTaskMaterialBox']['id'])->delete();
- parent::tearDown();
- }
- }
|