InventoryService_SomeTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Tests\Inventory\Services\InventoryService;
  3. use App\Inventory;
  4. use App\Services\InventoryService;
  5. use Tests\TestCase;
  6. class InventoryService_SomeTest extends TestCase
  7. {
  8. public $inventories;
  9. public $inventorys;
  10. public $queryParam=[];
  11. public $first;
  12. public $second;
  13. function setUp(): void
  14. {
  15. parent::setUp(); // TODO: Change the autogenerated stub
  16. $this->first=factory(Inventory::class)->create();
  17. $this->second=factory(Inventory::class)->create();
  18. }
  19. function testSome(){
  20. $this->queryParam=[
  21. 'data'=>'"'.$this->first['id'].','.$this->second['id'].'"',
  22. ];
  23. $inventoryService=new InventoryService();
  24. $this->inventories=$inventoryService->some($this->queryParam);
  25. $this->inventorys=Inventory::query()->with(['owner'])->orderBy('id','DESC')
  26. ->whereIn('id',explode(',','"'.$this->first['id'].','.$this->second['id'].'"'))->get();
  27. $this->assertEquals(count($this->inventorys),count($this->inventories));
  28. $this->assertEquals($this->inventorys,$this->inventories);
  29. }
  30. function tearDown(): void
  31. {
  32. Inventory::where('id',$this->first['id'])->forceDelete();
  33. Inventory::where('id',$this->second['id'])->forceDelete();
  34. parent::tearDown(); // TODO: Change the autogenerated stub
  35. }
  36. }