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