| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace Tests\Services;
- use App\OwnerFeeDetail;
- use App\Services\OwnerFeeDetailService;
- use Illuminate\Database\Eloquent\Collection;
- use Illuminate\Support\Facades\DB;
- use Tests\TestCase;
- class OwnerFeeDetailServiceTest extends TestCase
- {
- /** @var OwnerFeeDetailService */
- public $service;
- /** @var Collection */
- public $data;
- protected function setUp(): void
- {
- parent::setUp();
- $this->service = app(OwnerFeeDetailService::class);
- $this->data = factory(OwnerFeeDetail::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 testGetSql()
- {
- $ids = implode(",",array_column($this->data->toArray(),"id"));
- $sql = $this->service->getSql(["id"=>$ids]);
- $models = DB::select(DB::raw($sql));
- $this->assertCount(3,$models);
- }
- public function testTruncate(){
- OwnerFeeDetail::query()->truncate();
- $models = OwnerFeeDetail::query()->get();
- $this->assertCount(0,$models);
- }
- }
|