service = app(OwnerBillReportService::class); $this->data = factory(OwnerBillReport::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],[ "difference" => 1000, ]); $this->assertEquals(1,$result); $bill = OwnerBillReport::query()->find($model->id); $this->assertNotNull($bill); $this->assertEquals(1000,$bill->difference); } 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(){ OwnerBillReport::query()->truncate(); $models = OwnerBillReport::query()->get(); $this->assertCount(0,$models); } }