| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace Tests\Inventory\Services\InventoryAccountService;
- use App\InventoryAccount;
- use App\Services\InventoryAccountService;
- use Tests\TestCase;
- class InventoryAccountService_PaginateTest extends TestCase
- {
- public $inventories;
- public $inventorys;
- public $queryParam=[];
- //没有任何搜索条件情况
- function testPaginateSuccess(){
- $inventoryService=new InventoryAccountService();
- $this->inventories=$inventoryService->paginate($this->queryParam);
- $this->inventorys=InventoryAccount::get();
- $this->assertEquals(count($this->inventorys),$this->inventories->total());
- $this->assertEquals(50,$this->inventories->perPage());
- }
- //有搜索条件的情况
- function testPaginateSuccessHasParam(){
- $this->queryParam=[
- "owner_id" => "3",
- "paginate" => "100",
- ];
- $inventoryService=new InventoryAccountService();
- $this->inventories=$inventoryService->paginate($this->queryParam);
- $this->inventorys=InventoryAccount::where('owner_id',3)->get();
- $this->assertEquals(count($this->inventorys),$this->inventories->total());
- $this->assertEquals(100,$this->inventories->perPage());
- }
- }
|