GetWareHouseByCodeTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Tests\Services\WarehouseService;
  3. use App\OracleBasCustomer;
  4. use App\Services\OwnerService;
  5. use App\Services\WarehouseService;
  6. use App\Warehouse;
  7. use Illuminate\Foundation\Testing\RefreshDatabase;
  8. use Illuminate\Foundation\Testing\WithFaker;
  9. use Tests\TestCase;
  10. class GetWareHouseByCodeTest extends TestCase
  11. {
  12. use RefreshDatabase;
  13. /** @var WarehouseService $service */
  14. private $service;
  15. private $data;
  16. public function setUp(): void
  17. {
  18. parent::setUp(); // TODO: Change the autogenerated stub
  19. $this->service = app('WarehouseService');
  20. $basCustomers = OracleBasCustomer::query()->selectRaw('CustomerId,Descr_C')->where('Customer_Type','WH')->get();
  21. $this->data['basCustomers'] = $basCustomers;
  22. $this->data['codes'] = $basCustomers->map(function ($basCustomer){
  23. return $basCustomer->customerid;
  24. });
  25. }
  26. /**
  27. * @test
  28. */
  29. public function getWareHouseByCodeTest()
  30. {
  31. $wareHouses = $this->service->getWareHouseByCode($this->data['codes']);
  32. $this->assertNotEmpty($wareHouses);
  33. foreach ($wareHouses as $wareHouse) {
  34. $basCustomer = $this->data['basCustomers']->where('customerid',$wareHouse->code)->where('descr_c',$wareHouse->name);
  35. $this->assertNotEmpty($basCustomer);
  36. }
  37. foreach ($this->data['basCustomers'] as $basCustomer) {
  38. $wareHouse = $wareHouses->where('name',$basCustomer['descr_c'])->where('code',$basCustomer['customerid']);
  39. $this->assertNotEmpty($wareHouse);
  40. }
  41. }
  42. public function tearDown(): void
  43. {
  44. cache()->flush();
  45. parent::tearDown(); // TODO: Change the autogenerated stub
  46. }
  47. }