瀏覽代碼

海柔测试

LD 5 年之前
父節點
當前提交
3f57d4a8a1

+ 2 - 2
app/Traits/TestMockSubServices.php

@@ -33,7 +33,7 @@ trait TestMockSubServices{
         return $mockingService;
         return $mockingService;
     }
     }
 
 
-    function getTargetIdRecursively($targetArr, $additionMark='',$id){
+    function getTargetIdCirculately($targetArr, $additionMark='', $idName='id'){
         $amount = count($this->data['batches']);
         $amount = count($this->data['batches']);
         $iName = 'i_' . md5(json_encode($targetArr) . $additionMark);
         $iName = 'i_' . md5(json_encode($targetArr) . $additionMark);
         if(!isset($this->data[$iName])){
         if(!isset($this->data[$iName])){
@@ -42,6 +42,6 @@ trait TestMockSubServices{
         $this->data['$iName']++;
         $this->data['$iName']++;
         if($this->data['$iName']>=$this->batchAmount)
         if($this->data['$iName']>=$this->batchAmount)
             $this->data['$iName']=0;
             $this->data['$iName']=0;
-        return $targetArr[$this->data['$iName']]['id'];
+        return $targetArr[$this->data['$iName']][$idName];
     }
     }
 }
 }

+ 1 - 8
tests/Services/StationTaskMaterialBoxService/CreateByBatchesTest.php

@@ -28,14 +28,7 @@ class CreateByBatchesTest extends TestCase
         $this->data['orders']
         $this->data['orders']
             = factory(Order::class, $this->orderAmount)
             = factory(Order::class, $this->orderAmount)
             ->create([
             ->create([
-                'batch_id'=>(function(){
-                    if(!isset($this->data['i_batch_id_orders'])){
-                        $this->data['i_batch_id_orders']=$this->batchAmount;
-                    }
-                    $this->data['i_batch_id_orders']++;
-                    if($this->data['i_batch_id_orders']>=$this->batchAmount)$this->data['i_batch_id_orders']=0;
-                    return $this->data['batches'][$this->data['i_batch_id_orders']];
-                })()
+                'batch_id'=>$this->getTargetIdCirculately($this->data['batches'])
             ]);
             ]);
         $this->data['materialBoxes']
         $this->data['materialBoxes']
             = factory(StationTaskMaterialBox::class, $this->materialBoxAmount)
             = factory(StationTaskMaterialBox::class, $this->materialBoxAmount)