|
|
@@ -0,0 +1,72 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Tests\Services\ForeignHaiRoboticsService;
|
|
|
+use App\Exceptions\ErrorException;
|
|
|
+use App\MaterialBox;
|
|
|
+use App\Services\ForeignHaiRoboticsService;
|
|
|
+use App\Station;
|
|
|
+use App\StationTaskMaterialBox;
|
|
|
+use Tests\TestCase;
|
|
|
+use App\ForeignHaiRobotics;
|
|
|
+use App\Traits\TestMockSubServices;
|
|
|
+
|
|
|
+class TaskUpdateTest extends TestCase
|
|
|
+{
|
|
|
+ use TestMockSubServices;
|
|
|
+ /** @var ForeignHaiRoboticsService $service */
|
|
|
+ public $service;
|
|
|
+ private $data;
|
|
|
+ private $amount=2;
|
|
|
+ function setUp(): void
|
|
|
+ {
|
|
|
+ parent::setUp();
|
|
|
+ $this->service = app('ForeignHaiRoboticsService');
|
|
|
+ $this->data['station'] = factory(Station::class)->create();
|
|
|
+ $this->data['materialBox'] = factory(MaterialBox::class)->create();
|
|
|
+ $this->data['stationTaskMaterialBox'] = factory(StationTaskMaterialBox::class)->create([
|
|
|
+ 'station_id' => 1,
|
|
|
+ 'material_box_id' => $this->data['materialBox']['id'],
|
|
|
+
|
|
|
+ ]);
|
|
|
+ $this->data['task']=[
|
|
|
+ 'taskCode'=>md5(microtime(true)),
|
|
|
+ 'updateEventType' => 0,
|
|
|
+ 'status'=>0,
|
|
|
+ 'binCode'=>factory(MaterialBox::class)->create()
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testReturned()
|
|
|
+ {
|
|
|
+ $this->assertTrue(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testMissionFailed()
|
|
|
+ {
|
|
|
+ $this->data['task']['status']=1;
|
|
|
+ $this->assertFalse($this->service->taskUpdate(
|
|
|
+ $this->data['task']['taskCode'],
|
|
|
+ $this->data['task']['updateEventType'],
|
|
|
+ $this->data['task']['status'],
|
|
|
+ $this->data['task']['binCode']
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ public function testMissionFailed()
|
|
|
+ {
|
|
|
+ $this->data['task']['status']=1;
|
|
|
+ $this->assertFalse($this->service->taskUpdate(
|
|
|
+ $this->data['task']['taskCode'],
|
|
|
+ $this->data['task']['updateEventType'],
|
|
|
+ $this->data['task']['status'],
|
|
|
+ $this->data['task']['binCode']
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ function tearDown(): void
|
|
|
+ {
|
|
|
+ MaterialBox::query()
|
|
|
+ ->whereIn('id',[$this->data['task']['binCode']['id']??''])
|
|
|
+ ->delete();
|
|
|
+ parent::tearDown();
|
|
|
+ }
|
|
|
+}
|