InventoryService_PaginateTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Tests\Inventory\Services\InventoryService;
  3. use App\Inventory;
  4. use App\Services\InventoryService;
  5. use Tests\TestCase;
  6. class InventoryService_PaginateTest extends TestCase
  7. {
  8. public $inventories;
  9. public $inventorys;
  10. public $queryParam=[];
  11. //没有任何搜索条件情况
  12. function testPaginateSuccess(){
  13. $inventoryService=new InventoryService();
  14. $this->inventories=$inventoryService->paginate($this->queryParam);
  15. $this->inventorys=Inventory::get();
  16. $this->assertEquals(count($this->inventorys),$this->inventories->total());
  17. $this->assertEquals(50,$this->inventories->perPage());
  18. }
  19. //有搜索条件的情况
  20. function testPaginateSuccessHasParam(){
  21. $this->queryParam=[
  22. "owner_id" => "3",
  23. "paginate" => "100",
  24. ];
  25. $inventoryService=new InventoryService();
  26. $this->inventories=$inventoryService->paginate($this->queryParam);
  27. $this->inventorys=Inventory::where('owner_id',3)->get();
  28. $this->assertEquals(count($this->inventorys),$this->inventories->total());
  29. $this->assertEquals(100,$this->inventories->perPage());
  30. }
  31. }