我正在阅读单元测试,它包含这两个功能 assertArrayHasKey()和assertEquals()
请通过以下代码的上下文解释它们之间的区别。
// Test all basic required params were set
$options = $getReportInstance->getOptions();
$this->assertArrayHasKey('AWSAccessKeyId', $options, "Option AWSAccessKeyId doesn't exit");
$this->assertEquals(self::APP_ACCESS_KEY, $options['AWSAccessKeyId'], "AWSAccessKeyId was not set correctly!");
$this->assertArrayHasKey('SignatureMethod', $options, "Option SignatureMethod doesn't exist");
$this->assertEquals(
self::SIGNATURE_METHOD,
$options['SignatureMethod'],
"SignatureMethod was not set correctly!"
);
答案 0 :(得分:0)
如果数组中包含您输入的键的值,则assertArrayHasKey断言。值是否存在?
如果值与您预期的值相同,则assertEquales断言。价值是否正确?
所以他们都测试别的东西。第一个测试值是否存在,第二个测试值是否与您预期的值相同。