|
|
@@ -2,7 +2,10 @@
|
|
|
|
|
|
|
|
|
namespace Tests\Services\CacheShelfService;
|
|
|
+
|
|
|
use App\Services\CacheShelfService;
|
|
|
+use App\Station;
|
|
|
+use App\StationCacheShelfGrid;
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
class GetTasksTest extends TestCase
|
|
|
@@ -10,15 +13,35 @@ class GetTasksTest extends TestCase
|
|
|
/** @var CacheShelfService $service */
|
|
|
protected $service;
|
|
|
|
|
|
+ protected $data = [];
|
|
|
+
|
|
|
protected function setup(): void
|
|
|
{
|
|
|
+ parent::setup();
|
|
|
+
|
|
|
$this->service = app(CacheShelfService::class);
|
|
|
+ $this->data['station'] = factory(Station::class)->create();
|
|
|
+ $collect = collect();
|
|
|
+ for ($i = 1; $i <= 8; $i++) {
|
|
|
+ $collect->push(StationCacheShelfGrid::query()->create([
|
|
|
+ 'station_id' => $this->data['station']['id'] ?? '',
|
|
|
+ 'grid_id' => $i,
|
|
|
+ 'status' => 1,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ $this->data['grids'] = $collect;
|
|
|
+ }
|
|
|
|
|
|
- parent::setup(); // todo: change the autogenerated stub
|
|
|
+ public function testGetTasks()
|
|
|
+ {
|
|
|
+ $grids = $this->service->getTasks($this->data['station']);
|
|
|
+ $this->assertEquals(count($grids), count($this->data['grids']));
|
|
|
}
|
|
|
|
|
|
protected function tearDown(): void
|
|
|
{
|
|
|
+ Station::query()->where('id', $this->data['station']['id'])->delete();
|
|
|
+ StationCacheShelfGrid::query()->where('station_id', $this->data['station']['id'])->delete();
|
|
|
parent::tearDown(); // TODO: Change the autogenerated stub
|
|
|
}
|
|
|
|