| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace Tests\Services;
- use App\OwnerAreaReport;
- use App\Services\OwnerAreaReportService;
- use Illuminate\Database\Eloquent\Collection;
- use Tests\TestCase;
- class OwnerAreaReportServiceTest extends TestCase
- {
- /** @var OwnerAreaReportService */
- public $service;
- /** @var Collection */
- public $data;
- protected function setUp(): void
- {
- parent::setUp();
- $this->service = app(OwnerAreaReportService::class);
- $this->data = factory(OwnerAreaReport::class,3)->create();
- }
- public function testPaginate()
- {
- $models = $this->service->paginate(array("paginate"=>5));
- $this->assertGreaterThanOrEqual(3,count($models));
- $this->assertLessThanOrEqual(5,count($models));
- }
- public function testUpdate(){
- $model = $this->data[0];
- $result = $this->service->update(["id"=>$model->id],[
- "accounting_area" => 1000,
- ]);
- $this->assertEquals(true,$result);
- $area = OwnerAreaReport::query()->find($model->id);
- $this->assertNotNull($area);
- $this->assertEquals(1000,$area->accounting_area);
- }
- public function testGet(){
- $ids = implode(",",array_column($this->data->toArray(),"owner_id"));
- $models = $this->service->get(["owner_id"=>$ids]);
- $this->assertGreaterThanOrEqual(3,count($models));
- }
- public function testTruncate(){
- OwnerAreaReport::query()->truncate();
- $models = OwnerAreaReport::query()->get();
- $this->assertCount(0,$models);
- }
- }
|