LD преди 5 години
родител
ревизия
d556d76244
променени са 2 файла, в които са добавени 21 реда и са изтрити 10 реда
  1. 1 2
      tests/Services/CityService/FindByNameTest.php
  2. 20 8
      tests/Services/StationTaskBatchService/CreateByBatchesTest.php

+ 1 - 2
tests/Services/CityService/FindByNameTest.php

@@ -1,11 +1,10 @@
 <?php
 
-namespace Tests\Services\CityService\FindByNameTest;
+namespace Tests\Services\CityService;
 
 use App\City;
 use App\Services\CityService;
 use Illuminate\Foundation\Testing\RefreshDatabase;
-use Illuminate\Foundation\Testing\WithFaker;
 use Tests\TestCase;
 
 class FindByNameTest extends TestCase

+ 20 - 8
tests/Services/StationTaskBatchService/CreateByBatchesTest.php

@@ -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();
     }
 }