| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace Tests\Services\OwnerService;
- use App\OracleBasCustomer;
- use App\Owner;
- use App\Services\OwnerService;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Tests\TestCase;
- class GetOwnerByCodeTest extends TestCase
- {
- use RefreshDatabase;
- /** @var OwnerService $service */
- private $service;
- private $data = [];
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- cache()->flush();
- $basCustomer = factory(OracleBasCustomer::class)->make([]);
- $this->data['owner'] = factory(Owner::class)->create();
- $this->data['basCustomer'] = $basCustomer;
- $this->service = app('OwnerService');
- $this->mock('OracleBasCustomerService',function ($mock)use($basCustomer){
- $mock->shouldReceive('first')->andReturn($basCustomer);
- });
- }
- /**
- * @test
- */
- public function getOwnerByCode()
- {
- $owner = $this->service->getOwnerByCode($this->data['owner']['code']);
- $this->assertEquals($owner->id,$this->data['owner']['id']);
- $this->assertEquals($owner->name,$this->data['owner']['name']);
- }
- /**
- * @test
- */
- public function ownerIsNotExist()
- {
- $this->data['owner']->delete();
- $owner = $this->service->getOwnerByCode($this->data['owner']['code']);
- $this->assertEquals($owner->code,$this->data['basCustomer']['customerid']);
- $this->assertEquals($owner->name,$this->data['basCustomer']['descr_c']);
- $this->data['owner']= $owner;
- }
- public function tearDown(): void
- {
- cache()->flush();
- $this->data['owner']->delete();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|