PutBinToStoreTest.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Tests\Services\CacheShelfService;
  3. use App\MaterialBox;
  4. use App\Services\CacheShelfService;
  5. use App\Services\ForeignHaiRoboticsService;
  6. use App\Services\StationCacheShelfGridService;
  7. use App\Station;
  8. use App\StationTaskMaterialBox;
  9. use App\Traits\TestMockSubServices;
  10. use Tests\TestCase;
  11. class PutBinToStoreTest extends TestCase
  12. {
  13. use TestMockSubServices;
  14. /** @var CacheShelfService $cacheShelfService */
  15. protected $cacheShelfService;
  16. protected $data =[];
  17. protected function setup(): void
  18. {
  19. parent::setup(); // todo: change the autogenerated stub
  20. $this->data['station'] = factory(Station::class)->create(['name' => 'test', 'code'=> 'test']);
  21. $this->data['materialBox'] = factory(MaterialBox::class)->create();
  22. $this->data['stationTaskMaterialBox'] = factory(StationTaskMaterialBox::class)->create([
  23. 'station_id' => $this->data['station']['id'],
  24. 'material_box_id' => $this->data['materialBox']['id'],
  25. 'status' => 1
  26. ]);
  27. $this->cacheShelfService = $this->subMock([
  28. 'class' => CacheShelfService::class,
  29. 'subService' => [
  30. // [
  31. // 'serviceName' => 'stationTaskMaterialBoxService',
  32. // 'class' => StationTaskMaterialBoxService::class,
  33. // 'methods' => [
  34. // 'createByStationMaterialBox' => $this->data['stationTaskMaterialBox']
  35. // ]
  36. // ],
  37. [
  38. 'serviceName' => 'stationCacheShelfGridService',
  39. 'class' => StationCacheShelfGridService::class,
  40. 'methods' => [
  41. 'processGrid' => null
  42. ]
  43. ],
  44. [
  45. 'serviceName' => 'foreignHaiRoboticsService',
  46. 'class' => ForeignHaiRoboticsService::class,
  47. 'methods' => [
  48. // 'putBinToStore_fromCacheShelf' => true,
  49. 'controlHaiRobot' => true
  50. ]
  51. ]
  52. ]
  53. ]);
  54. }
  55. public function testPutBinToStore()
  56. {
  57. $bool = $this->cacheShelfService->putBinToStore($this->data['station'],);
  58. $boxTask = StationTaskMaterialBox::query()->where('station_id',$this->data['station']['id'])->where('material_box_id',$this->data['materialBox']['id'])->first();
  59. $this->assertTrue($bool);
  60. $this->assertNotEmpty($boxTask);
  61. $this->assertEquals($boxTask['status'],'待处理');
  62. }
  63. protected function tearDown(): void
  64. {
  65. Station::query()->where('id',$this->data['station']['id'])->delete();
  66. MaterialBox::query()->where('id',$this->data['materialBox']['id'])->delete();
  67. StationTaskMaterialBox::query()->where('id',$this->data['stationTaskMaterialBox']['id'])->delete();
  68. parent::tearDown();
  69. }
  70. }