[英]PHP Unit Notice: Array to string conversion
I'm using strtotime() in PHP to get the days of a week (I made a calendar, with different views, so it changes). 我在PHP中使用strtotime()获取星期几(我制作了一个日历,具有不同的视图,因此它会发生变化)。 PHP Unit gives me the warning of Array to string conversion whenever I try this:
每当我尝试这样做时,PHP Unit都会警告我将数组转换为字符串:
$monday = date('Y-m-d', strtotime($sunday . '+ 1 day'));
$sunday is a variable that I get this way: $ sunday是我这样获得的变量:
public function GetWeekRange($date) {
$ts = strtotime($date);
$start = (date('w', $ts) == 0) ? $ts : strtotime('last sunday', $ts);
return date('Y-m-d', $start);
}
and $date is a string in the format 'YYYY-mm-dd' $ date是格式为“ YYYY-mm-dd”的字符串
I'm not sure why I get this error, the code works just fine, but the test gives that warning, and it's going to give a warning on my environment where all the different projects are shown (red/green depending on whether there's a failure or not). 我不确定为什么会收到此错误,代码可以正常工作,但是测试给出了警告,并且它将在显示所有不同项目的环境中发出警告(红色/绿色,取决于是否有是否失败)。
Thanks, 谢谢,
Fer 费尔
Rookie mistake: I updated the function to return only one string, but the mocked value I kept as an array. 新手错误:我将函数更新为仅返回一个字符串,但模拟值保留为数组。
My bad. 我的错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.