while ($r = $q->fetch()) {
$image_folder = "folder_name/";
$image_id = $r['product_id'].".jpg";
$new_imagePath = $image_folder . imageExists($image_id,$image_folder);
echo "<a href='". $imagePath ."'><img class='product' height='' src='". $new_imagePath ."' alt='". $r['product_id'] ."-". str_replace("'", "", $r['product_name']) . "' title='". str_replace("'", "", $r['product_name']) ."' /></a>";
}
在测试中运行时,我收到以下错误:
org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 参数匹配器的使用无效!预期3个匹配者,2个记录:
答案 0 :(得分:0)
关于jdbcTemplate.queryForObject(query, namedParameters, Integer.class);
,您的设置应为:
Mockito.doReturn(myInteger).when(jdbcTemplateMock).queryForObject(Mockito.anyString()
, Mockito.any(Object[].class), Mockito.eq(Integer.class));
关于queryForObject(sql, paramMap, new SingleColumnRowMapper<>(requiredType));
,您的设置可能是:
Mockito.doReturn(myInteger)
.when(n)
.queryForObject(Mockito.anyString()
, ArgumentMatchers.<Map<Integer,?>>any()
, ArgumentMatchers.<org.springframework.jdbc.core.RowMapper<Integer>>any());