| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace Tests\Services\LogisticService;
- use App\Logistic;
- use App\OracleBasCustomer;
- use App\Services\LogisticService;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Tests\TestCase;
- class GetLogisticByCodeTest extends TestCase
- {
- /** @var LogisticService $service */
- private $service;
- private $data = [];
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->service = app('LogisticService');
- $logistic = factory(Logistic::class)->create(['code'=>'AABBCCDD1']);
- $basCustomer = factory(OracleBasCustomer::class)->make(["customer_type"=>'OW',"customerid"=>$logistic->code]);
- $this->data['basCustomers'] = $basCustomer;
- $this->data['logistic'] = $logistic;
- $this->mock('OracleBasCustomerService',function ($mock)use($basCustomer){
- $mock->shouldReceive('first')->andReturn($basCustomer);
- });
- }
- /**
- * @test
- */
- public function getLogisticByCode()
- {
- $logistic = $this->service->getLogisticByCode($this->data['logistic']['code']);
- $this->assertEquals($logistic->id,$this->data['logistic']['id']);
- $this->assertEquals($logistic->code,$this->data['logistic']['code']);
- $this->assertEquals($logistic->name,$this->data['logistic']['name']);
- }
- public function tearDown(): void
- {
- cache()->forget('getLogisticByCode_'.$this->data['logistic']['code']);
- $this->data['logistic']->delete();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|