| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?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();
- $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']->forceDelete();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|