| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace Tests\Services\WarehouseService;
- use App\OracleBasCustomer;
- use App\Services\OracleBasCustomerService;
- use App\Services\WarehouseService;
- use App\Warehouse;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Tests\TestCase;
- class GetWareHouseByCodeTest extends TestCase
- {
- /** @var WarehouseService $service */
- private $service;
- private $data;
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->service = app('WarehouseService');
- $warehouse = factory(Warehouse::class)->create();
- $basCustomer = factory(OracleBasCustomer::class)->make(['customerid'=>$warehouse->code,'descr_c'=>$warehouse->name,'customer_type'=>'OW']);
- $this->data['warehouse'] = $warehouse;
- $this->data['code'] = $warehouse->code;
- $this->data['basCustomer'] = $basCustomer;
- $this->mock(OracleBasCustomerService::class,function($mock)use($basCustomer){
- $mock->shouldReceive('first')->andReturn($basCustomer);
- });
- }
- /**
- * @test
- */
- public function getWareHouseByCodeTest()
- {
- $warehouse = $this->service->getWareHouseByCode($this->data['code']);
- $this->assertEquals($warehouse->toArray(),$this->data['warehouse']->toArray());
- }
- /**
- * @test
- */
- public function warehouseIsNotExist(){
- $this->data['warehouse']->delete();
- cache()->forget('WareHouse_'.$this->data['warehouse']->code);
- $warehouse = $this->service->getWareHouseByCode($this->data['code']);
- $this->data['warehouse'] = $warehouse;
- $this->assertEquals($warehouse['name'],$this->data['basCustomer']['descr_c']);
- $this->assertEquals($warehouse['code'],$this->data['basCustomer']['customerid']);
- }
- public function tearDown(): void
- {
- $this->data['warehouse']->delete();
- cache()->forget('WareHouse_'.$this->data['warehouse']->code);
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|