Get_OnlyownerIdsTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Tests\Services\CommodityService;
  3. use App\Commodity;
  4. use App\CommodityBarcode;
  5. use App\OracleBasSKU;
  6. use App\Owner;
  7. use App\Services\CommodityService;
  8. use Tests\TestCase;
  9. class Get_OnlyownerIdsTest extends TestCase
  10. {
  11. /** @var CommodityService $service */
  12. private $service;
  13. private $data = [];
  14. public function setUp(): void
  15. {
  16. parent::setUp(); // TODO: Change the autogenerated stub
  17. $this->service = app('CommodityService');
  18. $owner = factory(Owner::class)->create();
  19. $commodity=factory(Commodity::class)->create(['owner_id'=>$owner->id]);
  20. $this->data['owner'] = $owner;
  21. $this->data['commodity'] = $commodity;
  22. }
  23. public function testGet_OnlyOwnerIds()
  24. {
  25. $commodities=$this->service->get_([$this->data['commodity']['owner_id']]);
  26. $this->assertNotNull($commodities);
  27. $this->assertEquals($this->data['commodity']['sku'],$commodities->first()['sku']);
  28. }
  29. public function tearDown(): void
  30. {
  31. $commodity_id=Commodity::query()->where('owner_id',$this->data['commodity']['owner_id'])->value('id');
  32. Commodity::query()->where('owner_id',$this->data['owner']['id'])->delete();
  33. CommodityBarcode::query()->where('commodity_id',$commodity_id)->delete();
  34. $this->data['owner']->delete();
  35. $this->data['commodity']->delete();
  36. parent::tearDown(); // TODO: Change the autogenerated stub
  37. }
  38. }