TaskUpdateTest.php 2.1 KB

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