|
|
@@ -2,35 +2,47 @@
|
|
|
|
|
|
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 testCreateSuccess()
|
|
|
-// {
|
|
|
-// $amountToCreate=3;
|
|
|
-// $this->data['stationTasks']=$this->service->create($amountToCreate);
|
|
|
-// $this->assertEquals(Collection::class,get_class($this->data['stationTasks']));
|
|
|
-// $this->assertEquals($amountToCreate,$this->data['stationTasks']->count());
|
|
|
-// $this->assertEquals(StationTask::class,get_class($this->data['stationTasks'][0]));
|
|
|
-// }
|
|
|
+ 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();
|
|
|
}
|
|
|
}
|