2

I have an assertion to check a key in an array in my CodeCeption tests. The test calls a REST API and checks the returned response.

I have this command:

$I->assertContains("key", $resp);

The output is:

Step  Assert contains "key",{"key":"0m-5m","price":10000,"text":"۰ تا ۵ دقیقه"}
Fail  Failed asserting that an array contains 'key'.

But when I change the command to the following, everything works fine:

$I->assertInternalType("string", $resp["key"]);

This behavior shows that there is a key named key in my $resp object.

I supposed that the cause may be the UTF-8 characters, since I've been using asserContains a hundred times before and it works as a charm.

Any idea how to solve the issue?

1 Answer 1

3

I tried another assert method of CodeCeption which worked fine for me.

$I->assertArrayHasKey("key", $resp);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.