2017-04-12 91 views
0

斷言參數列表我想在php單元測試用例如何使用嘲弄

public function getTrack(TrackOption $trackOptions) 
    { 
     try { 
      $buildCondition = array(); 
      $sql = 'SELECT * 
       FROM xyz tbl' 
      $where = " WHERE 1"; 

      if ($name) { 
       $where = " AND tbl.name =".$name; 
      } 
      $sql .= $where; 
      $rsm = new ResultSetMapping(); 

      $query = $this->_rcEm->createNativeQuery($sql, $rsm); 
      $results = $query->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY); 
      return $results; 
     } catch (\Exception $e) { 
      die($e->getMessage()); 
     } 
    } 

我想斷言$sql與預期值使用嘲諷斷言和我的預期值的參數值。 任何幫助.........

回答

0

在嘲笑你的

$mock->shouldReceive('createNativeQuery') 
->with('my-expected sql', \Mockery::type(ResultSetMapping::class)); 

做到這一點如果你havn`t發現已經