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

PHP while loop dynamic rowspan -

timer - Java TimerTask cancel -

android - How to read a column value in parse.com without accessing an object or a pointer -