|
|
@@ -22,22 +22,22 @@ class GetOwnerByCodesTest extends TestCase
|
|
|
parent::setUp(); // TODO: Change the autogenerated stub
|
|
|
$this->service = app('OwnerService');
|
|
|
|
|
|
- $owner1 = factory(Owner::class)->create();
|
|
|
- $owner2 = factory(Owner::class)->create();
|
|
|
- $owner3 = factory(Owner::class)->create();
|
|
|
+ $owner1 = factory(Owner::class)->create(['code'=>'AABBCC1']);
|
|
|
+ $owner2 = factory(Owner::class)->create(['code'=>'AABBCC2']);
|
|
|
+ $owner3 = factory(Owner::class)->create(['code'=>'AABBCC3']);
|
|
|
|
|
|
$this->data['owner'] = [$owner1,$owner2,$owner3];
|
|
|
$this->service = app('OwnerService');
|
|
|
|
|
|
- $basCustomer1 = factory(OracleBasCustomer::class)->make(["customer_type"=>'OW',"customerid"=>$owner1->code]);
|
|
|
- $basCustomer2 = factory(OracleBasCustomer::class)->make(["customer_type"=>'OW',"customerid"=>$owner2->code]);
|
|
|
- $basCustomer3 = factory(OracleBasCustomer::class)->make(["customer_type"=>'OW',"customerid"=>$owner3->code]);
|
|
|
+ $basCustomer1 = factory(OracleBasCustomer::class)->make(["customer_type"=>'OW',"customerid"=>'AABBCC1']);
|
|
|
+ $basCustomer2 = factory(OracleBasCustomer::class)->make(["customer_type"=>'OW',"customerid"=>'AABBCC2']);
|
|
|
+ $basCustomer3 = factory(OracleBasCustomer::class)->make(["customer_type"=>'OW',"customerid"=>'AABBCC3']);
|
|
|
$basCustomers = collect([$basCustomer1,$basCustomer2,$basCustomer3]);
|
|
|
|
|
|
$this->mock('OracleBasCustomerService',function ($mock)use($basCustomers,$owner1, $owner2, $owner3){
|
|
|
- $mock->shouldReceive('first')->once()->with(["customer_type"=>'OW',"customerid"=>$owner1->code])->andReturn($basCustomers->where('customerid',$owner1->code)->first());
|
|
|
- $mock->shouldReceive('first')->once()->with(["customer_type"=>'OW',"customerid"=>$owner2->code])->andReturn($basCustomers->where('customerid',$owner2->code)->first());
|
|
|
- $mock->shouldReceive('first')->once()->with(["customer_type"=>'WO',"customerid"=>$owner3->code])->andReturn($basCustomers->where('customerid',$owner3->code)->first());
|
|
|
+ $mock->shouldReceive('first')->with(["Customer_Type"=>'OW',"CustomerID"=>$owner1->code])->andReturn($basCustomers->where('customerid',$owner1->code)->first());
|
|
|
+ $mock->shouldReceive('first')->with(["Customer_Type"=>'OW',"CustomerID"=>$owner2->code])->andReturn($basCustomers->where('customerid',$owner2->code)->first());
|
|
|
+ $mock->shouldReceive('first')->with(["Customer_Type"=>'OW',"CustomerID"=>$owner3->code])->andReturn($basCustomers->where('customerid',$owner3->code)->first());
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -50,7 +50,7 @@ class GetOwnerByCodesTest extends TestCase
|
|
|
$this->assertNotNull($owners);
|
|
|
$this->assertNotEquals(count($owners),0);
|
|
|
$this->assertNotEquals(count($owners),1);
|
|
|
- $this->assertEquals(count($owners),count($this->data['owner']['code']));
|
|
|
+ $this->assertEquals(count($owners),count($this->data['owner']));
|
|
|
foreach ($this->data['owner'] as $item) {
|
|
|
$owner = $owners->where('code',$item['code'])->first();
|
|
|
$this->assertEquals($owner->id,$item['id']);
|
|
|
@@ -70,19 +70,20 @@ class GetOwnerByCodesTest extends TestCase
|
|
|
$this->assertNotNull($owners);
|
|
|
$this->assertNotEquals(count($owners),0);
|
|
|
$this->assertNotEquals(count($owners),1);
|
|
|
- $this->assertEquals(count($owners),count($this->data['owner']['code']));
|
|
|
+ $this->assertEquals(count($owners),count($this->data['owner']));
|
|
|
+
|
|
|
foreach ($this->data['owner'] as $item) {
|
|
|
$owner = $owners->where('code',$item['code'])->first();
|
|
|
- $this->assertEquals($owner->id,$item['id']);
|
|
|
- $this->assertEquals($owner->name,$item['name']);
|
|
|
$this->assertEquals($owner->code,$item['code']);
|
|
|
}
|
|
|
+
|
|
|
+ $this->data['owner'] = $owners;
|
|
|
}
|
|
|
|
|
|
public function tearDown(): void
|
|
|
{
|
|
|
- cache()->flush();
|
|
|
foreach ($this->data['owner'] as $owner) {
|
|
|
+ cache()->forget("getOwnerByCode_{$owner['code']}");
|
|
|
$owner->delete();
|
|
|
}
|
|
|
parent::tearDown(); // TODO: Change the autogenerated stub
|