service = app('StationRuleBatchService'); $this->batchService = app('BatchService'); $this->data['owner_target'] = factory(Owner::class)->create(); $this->data['stationRuleBatch'] = factory(StationRuleBatch::class) ->create([ 'owner_id' => $this->data['owner_target']['id'], ]); $this->data['batches'] = factory(Batch::class, $this->amountOfInRule)->create([ 'owner_id' => $this->data['owner_target']['id'], ]); $this->data['stationTaskBatch']=collect(); $this->data['order']=collect(); foreach ($this->data['batches'] as $batch){ $this->data['stationTaskBatch'] ->push(factory(StationTaskBatch::class)->create(['batch_id' => $batch['id'],])); $this->data['order']->push(factory(Order::class)->create(['batch_id' => $batch['id'],])); } $this->data['orderCommodities'] =collect(); foreach ($this->data['order'] as $order){ $this->data['orderCommodities']->push( factory(OrderCommodity::class)->create(['order_id'=>$order['id'],'location'=>'IDE100'])); } } public function testFilteredOut() { $batches=$this->service->getBatches_shouldProcess($this->data['batches']); if($batches->count()==0) $this->assertEmpty($batches); if ($batches->count()>0)$this->assertEquals($this->amountOfInRule,$batches->count()); } public function tearDown(): void { Owner::query()->whereIn('id',[ $this->data['owner_target']['id'], ])->delete(); OrderCommodity::query()->whereIn('id',data_get($this->data['orderCommodities'],'*.id'))->delete(); StationTaskBatch::query()->whereIn('batch_id',data_get($this->data['batches'],'*.id'))->delete(); Order::query()->whereIn('batch_id',data_get($this->data['batches'],'*.id'))->delete(); StationRuleBatch::query()->where('id',$this->data['stationRuleBatch']['id'])->delete(); Batch::query()->whereIn('id',data_get($this->data['batches'],'*.id'))->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }