| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace Tests\Services\StationTaskBatchService;
- use App\Batch;
- use App\Services\StationTaskBatchService;
- use App\Services\StationTaskService;
- use App\StationTask;
- use App\StationTaskBatch;
- use Tests\TestCase;
- class CreateByBatchesTest extends TestCase
- {
- /** @var StationTaskBatchService $service */
- private $service;
- /** @var StationTaskService $service */
- private $stationTaskService;
- private $data = [];
- const AmountOfBatch=3;
- public function setUp(): void
- {
- parent::setUp();
- $this->service = app('StationTaskBatchService');
- $this->stationTaskService = app('StationTaskService');
- $this->data['batches'] =
- factory(Batch::class, self::AmountOfBatch)
- ->create();
- $this->data['stationTasks'] =
- $this->stationTaskService->create(self::AmountOfBatch);
- }
- public function testReturned()
- {
- $this->data['stationTaskBatches']=$this->service->createByBatches($this->data['batches'], $this->data['stationTasks']);
- $this->assertEquals(self::AmountOfBatch, $this->data['stationTaskBatches']->count());
- }
- public function tearDown(): void
- {
- Batch::query()->whereIn('id',data_get($this->data['batches'],'*.id')??[])->delete();
- StationTask::query()->whereIn('id',data_get($this->data['stationTasks'],'*.id')??[])->delete();
- StationTaskBatch::query()->whereIn('id',data_get($this->data['stationTaskBatches'],'*.id')??[])->delete();
- parent::tearDown();
- }
- }
|