如何使用Mockery断言参数列表

时间:2017-04-12 11:06:14

标签: php unit-testing mockery

我想在php单元测试用例

中使用mockery断言我的期望值的参数值
 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。 任何帮助.........

1 个答案:

答案 0 :(得分:0)

在Mockery中,您可以通过

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

如果你已经发现了