TaskUpdateTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Tests\Services\ForeignHaiRoboticsService;
  3. use App\MaterialBox;
  4. use App\Services\ForeignHaiRoboticsService;
  5. use App\Station;
  6. use App\StationTaskMaterialBox;
  7. use Tests\TestCase;
  8. use App\Traits\TestMockSubServices;
  9. class TaskUpdateTest extends TestCase
  10. {
  11. use TestMockSubServices;
  12. /** @var ForeignHaiRoboticsService $service */
  13. public $service;
  14. private $data;
  15. private $amount=2;
  16. function setUp(): void
  17. {
  18. parent::setUp();
  19. $this->service = app('ForeignHaiRoboticsService');
  20. $this->data['station'] = factory(Station::class)->create();
  21. $this->data['materialBox'] = factory(MaterialBox::class)->create();
  22. $this->data['stationTaskMaterialBox'] = factory(StationTaskMaterialBox::class)->create([
  23. 'station_id' => 1,
  24. 'material_box_id' => $this->data['materialBox']['id'],
  25. ]);
  26. $this->data['task']=[
  27. 'taskCode'=>md5(microtime(true)),
  28. 'updateEventType' => 0,
  29. 'status'=>0,
  30. 'binCode'=>factory(MaterialBox::class)->create()
  31. ];
  32. }
  33. public function testReturned()
  34. {
  35. $this->assertTrue(true);
  36. }
  37. public function testMissionFailed()
  38. {
  39. $this->data['task']['status']=1;
  40. $this->assertFalse($this->service->taskUpdate(
  41. $this->data['task']['taskCode'],
  42. $this->data['task']['updateEventType'],
  43. $this->data['task']['status'],
  44. $this->data['task']['binCode']
  45. ));
  46. }
  47. public function testMissionFailed()
  48. {
  49. $this->data['task']['status']=1;
  50. $this->assertFalse($this->service->taskUpdate(
  51. $this->data['task']['taskCode'],
  52. $this->data['task']['updateEventType'],
  53. $this->data['task']['status'],
  54. $this->data['task']['binCode']
  55. ));
  56. }
  57. function tearDown(): void
  58. {
  59. MaterialBox::query()
  60. ->whereIn('id',[$this->data['task']['binCode']['id']??''])
  61. ->delete();
  62. parent::tearDown();
  63. }
  64. }