GetWareHouseByCodeTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Tests\Services\WarehouseService;
  3. use App\OracleBasCustomer;
  4. use App\Services\OracleBasCustomerService;
  5. use App\Services\WarehouseService;
  6. use App\Warehouse;
  7. use Illuminate\Foundation\Testing\RefreshDatabase;
  8. use Tests\TestCase;
  9. class GetWareHouseByCodeTest extends TestCase
  10. {
  11. use RefreshDatabase;
  12. /** @var WarehouseService $service */
  13. private $service;
  14. private $data;
  15. public function setUp(): void
  16. {
  17. parent::setUp(); // TODO: Change the autogenerated stub
  18. $this->service = app('WarehouseService');
  19. $warehouse = factory(Warehouse::class)->create();
  20. $basCustomer = factory(OracleBasCustomer::class)->make(['customerid'=>$warehouse->code,'descr_c'=>$warehouse->name]);
  21. $this->data['warehouse'] = $warehouse;
  22. $this->data['code'] = $warehouse->code;
  23. $this->data['basCustomer'] = $basCustomer;
  24. $this->mock(OracleBasCustomerService::class,function($mock)use($basCustomer){
  25. $mock->shouldReceive('first')->andReturn($basCustomer);
  26. });
  27. }
  28. /**
  29. * @test
  30. */
  31. public function getWareHouseByCodeTest()
  32. {
  33. $warehouse = $this->service->getWareHouseByCode($this->data['code']);
  34. $this->assertEquals($warehouse->toArray(),$this->data['warehouse']->toArray());
  35. }
  36. public function tearDown(): void
  37. {
  38. $this->data['warehouse']->delete();
  39. parent::tearDown(); // TODO: Change the autogenerated stub
  40. }
  41. }