2016-08-08 14 views
1

私がテストしている配列が正しいキーを持っていると主張するPHPUnitテストを作成しようとしています。配列キーがPHPUnitと一致する

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

$this->assertEquals($result, []); 

このテストは機能しますが、PHPUnit 4.8でこれを行うにはもっとクリーンな方法が必要ですか?

答えて

0

あなたは各キーのアサー書く必要があります。このヘルプ

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

希望を

関連する問題