Array keys match PHPUnit -


i'm trying write phpunit test asserts array testing has correct keys.

$structure = ['title', 'message', 'action']; $structure = array_flip($structure); $result = array_diff_key($structure, $response);  $this->assertequals($result, []); 

this test works, there must cleaner way phpunit 4.8?

you should write asserting each key:

$this->assertarrayhaskey('key', $response);   $this->assertarrayhaskey('message', $response);  $this->assertarrayhaskey('action', $response); 

hope help


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -