|
|
@@ -3,11 +3,10 @@
|
|
|
namespace Tests\Services\WarehouseService;
|
|
|
|
|
|
use App\OracleBasCustomer;
|
|
|
-use App\Services\OwnerService;
|
|
|
+use App\Services\OracleBasCustomerService;
|
|
|
use App\Services\WarehouseService;
|
|
|
use App\Warehouse;
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
-use Illuminate\Foundation\Testing\WithFaker;
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
class GetWareHouseByCodeTest extends TestCase
|
|
|
@@ -22,10 +21,13 @@ class GetWareHouseByCodeTest extends TestCase
|
|
|
{
|
|
|
parent::setUp(); // TODO: Change the autogenerated stub
|
|
|
$this->service = app('WarehouseService');
|
|
|
- $basCustomers = OracleBasCustomer::query()->selectRaw('CustomerId,Descr_C')->where('Customer_Type','WH')->get();
|
|
|
- $this->data['basCustomers'] = $basCustomers;
|
|
|
- $this->data['codes'] = $basCustomers->map(function ($basCustomer){
|
|
|
- return $basCustomer->customerid;
|
|
|
+ $warehouse = factory(Warehouse::class)->create();
|
|
|
+ $basCustomer = factory(OracleBasCustomer::class)->make(['customerid'=>$warehouse->code,'descr_c'=>$warehouse->name]);
|
|
|
+ $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);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -34,21 +36,14 @@ class GetWareHouseByCodeTest extends TestCase
|
|
|
*/
|
|
|
public function getWareHouseByCodeTest()
|
|
|
{
|
|
|
- $wareHouses = $this->service->getWareHouseByCode($this->data['codes']);
|
|
|
- $this->assertNotEmpty($wareHouses);
|
|
|
- foreach ($wareHouses as $wareHouse) {
|
|
|
- $basCustomer = $this->data['basCustomers']->where('customerid',$wareHouse->code)->where('descr_c',$wareHouse->name);
|
|
|
- $this->assertNotEmpty($basCustomer);
|
|
|
- }
|
|
|
- foreach ($this->data['basCustomers'] as $basCustomer) {
|
|
|
- $wareHouse = $wareHouses->where('name',$basCustomer['descr_c'])->where('code',$basCustomer['customerid']);
|
|
|
- $this->assertNotEmpty($wareHouse);
|
|
|
- }
|
|
|
+ $warehouse = $this->service->getWareHouseByCode($this->data['code']);
|
|
|
+ $this->assertEquals($warehouse->toArray(),$this->data['warehouse']->toArray());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public function tearDown(): void
|
|
|
{
|
|
|
- cache()->flush();
|
|
|
+ $this->data['warehouse']->delete();
|
|
|
parent::tearDown(); // TODO: Change the autogenerated stub
|
|
|
}
|
|
|
}
|