| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace Tests\Services\StationCacheShelfGrid;
- use App\Station;
- use App\StationCacheShelfGrid;
- use Tests\TestCase;
- class GetLocationTest extends TestCase
- {
- protected $data = [];
- protected function setUp(): void
- {
- parent::setUp();
- $row = 3;
- $col = 2;
- $this->data['grid_id'] = ($row-1)*3+$col;
- $this->data['station'] = factory(Station::class)->create();
- $this->data['grid'] = factory(StationCacheShelfGrid::class)->create(['station_id'=>$this->data['station']['id'],'grid_id'=>$this->data['grid_id']]);
- $this->data['code'] = 'HAI'.$this->data['station']['code'].'-0'. (2 - $col + 1).'-0'.(2-$row+1);
- }
- function testGetLocation()
- {
- $location = StationCacheShelfGrid::getLocation($this->data['station'],$this->data['grid']);
- $this->assertEquals($this->data['grid_id'],$this->data['grid']['grid_id']);
- $this->assertEquals($this->data['code'],$location);
- }
- protected function tearDown(): void
- {
- Station::query()->where('id',$this->data['station']['id'])->delete();
- StationCacheShelfGrid::query()->where('id',$this->data['grid']['id'])->delete();
- parent::tearDown();
- }
- }
|