GetLogisticByCodeTest.php 1.6 KB

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