|
|
@@ -5,7 +5,9 @@ use App\Batch;
|
|
|
use App\Order;
|
|
|
use App\OrderBin;
|
|
|
use App\OrderCommodity;
|
|
|
+use App\Services\StationRuleBatchService;
|
|
|
use App\Services\StationTaskCommodityService;
|
|
|
+use App\Services\StationTypeService;
|
|
|
use Tests\TestCase;
|
|
|
use App\StationTaskCommodity;
|
|
|
|
|
|
@@ -42,7 +44,7 @@ class CreateByBatchTest extends TestCase
|
|
|
return $this->data['batches'][$this->data['temBatchId_orders']];
|
|
|
})(),
|
|
|
]);
|
|
|
- $this->data['ordersBins'] =
|
|
|
+ $this->data['orderBins'] =
|
|
|
factory(OrderBin::class,
|
|
|
$this->orderAmount)
|
|
|
->create([
|
|
|
@@ -78,12 +80,33 @@ class CreateByBatchTest extends TestCase
|
|
|
|
|
|
public function testReturned()
|
|
|
{
|
|
|
- $this->data['stationTaskCommodities']=(function(){
|
|
|
+ ($mocking= function (){
|
|
|
+ $stationTypeServiceMock=$this->createPartialMock(
|
|
|
+ StationTypeService::class,
|
|
|
+ ['aaa']
|
|
|
+ );
|
|
|
+ $stationRuleBatchServiceStr = 'stationRuleBatchService';
|
|
|
+ $stationTypeServiceMock->app(
|
|
|
+ $stationRuleBatchServiceStr,
|
|
|
+ ($stationRuleBatchServiceMock=function(){
|
|
|
+ $mock=$this->createPartialMock(
|
|
|
+ StationTypeService::class,
|
|
|
+ ['aaa']
|
|
|
+ );
|
|
|
+ $mock->method('getByBatch')->willReturn('ddd');
|
|
|
+ return $mock;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ })();
|
|
|
+ $this->data['stationTaskCommodities']
|
|
|
+ =(function(){
|
|
|
if(!isset($this->data['stationTaskCommodities']))
|
|
|
$this->data['stationTaskCommodities'] = collect();
|
|
|
foreach($this->data['batches'] as $batch){
|
|
|
$this->data['stationTaskCommodities']
|
|
|
- =$this->data['stationTaskCommodities']->merge($this->service->createByBatch($batch));
|
|
|
+ =$this->data['stationTaskCommodities']->merge(
|
|
|
+ $this->service->createByBatch($batch)//<<---testing it
|
|
|
+ );
|
|
|
}
|
|
|
return $this->data['stationTaskCommodities'];
|
|
|
})();
|
|
|
@@ -95,6 +118,18 @@ class CreateByBatchTest extends TestCase
|
|
|
StationTaskCommodity::query()
|
|
|
->whereIn('id',data_get($this->data['stationTaskCommodities'],'*.id')??[])
|
|
|
->delete();
|
|
|
+ Batch::query()
|
|
|
+ ->whereIn('id',data_get($this->data['batches'],'*.id')??[])
|
|
|
+ ->delete();
|
|
|
+ Order::query()
|
|
|
+ ->whereIn('id',data_get($this->data['orders'],'*.id')??[])
|
|
|
+ ->delete();
|
|
|
+ OrderBin::query()
|
|
|
+ ->whereIn('id',data_get($this->data['orderBins'],'*.id')??[])
|
|
|
+ ->delete();
|
|
|
+ OrderCommodity::query()
|
|
|
+ ->whereIn('id',data_get($this->data['orderCommodities'],'*.id')??[])
|
|
|
+ ->delete();
|
|
|
parent::tearDown();
|
|
|
}
|
|
|
}
|