Do not call count on null

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-11-29 09:59:35 +01:00
parent a6ae8012ca
commit 330cb7047e
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
1 changed files with 6 additions and 2 deletions

View File

@ -256,8 +256,12 @@ class CommentsContext implements \Behat\Behat\Context\Context {
* @throws \Exception
*/
public function theResponseShouldContainOnlyComments($number) {
if (count($this->response) !== (int)$number) {
throw new \Exception("Found more comments than $number (" . count($this->response) . ")");
$count = 0;
if ($this->response !== null) {
$count = count($this->response);
}
if ($count !== (int)$number) {
throw new \Exception("Found more comments than $number (" . $count . ")");
}
}