| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace Tests\Services\CacheShelfService;
- use App\MaterialBox;
- use App\Services\CacheShelfService;
- use App\Services\ForeignHaiRoboticsService;
- use App\Services\StationTaskMaterialBoxService;
- use App\Services\StationTaskService;
- use App\Station;
- use App\Storage;
- use App\Traits\TestMockSubServices;
- use Tests\TestCase;
- class BindMaterialBoxTest extends TestCase
- {
- use TestMockSubServices;
- /** @var CacheShelfService $cacheShelfService*/
- public $cacheShelfService;
- public $data = [];
- protected function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->cacheShelfService = $this->subMock([
- 'class' => CacheShelfService::class,
- 'methods' => [
- '_stationCacheLightOn' => new MaterialBox(['code' => 200])
- ],
- ]);
- $this->data['station'] = factory(Station::class)->create();
- $this->data['materialBox'] = factory(MaterialBox::class)->create();
- $this->data['storage'] = factory(Storage::class)->create(['station_id' => $this->data['station']['id']]);
- }
- public function testBindMaterialBoxTest()
- {
- $result = $this->cacheShelfService->bindMaterialBox($this->data['station']['code'],$this->data['materialBox']['code']);
- $this->assertTrue($result['success']);
- $storage = Storage::query()->whereKey($this->data['storage']['id'])->first();
- $this->assertEquals($this->data['materialBox']['id'],$storage['material_box_id']);
- }
- protected function tearDown(): void
- {
- if($this->data['station'] ?? false) Station::query()->whereKey($this->data['station']['id'])->delete();
- if($this->data['materialBox'] ?? false) MaterialBox::query()->whereKey($this->data['materialBox']['id'])->delete();
- if($this->data['storage'] ?? false) Storage::query()->whereKey($this->data['storage']['id'])->delete();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|