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
Post a Comment