I was reading a Unit Test and it contains these two functions assertArrayHasKey() and assertEquals()
Please explain the difference between them by sitting in the context of below code.
// 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!"
);
The assertArrayHasKey asserts if the array has a value with the key you put in. Does the value exist?
The assertEquales asserts if the value is the same as you expect it to be. Is the value correct?
So they both test something else. The first tests if the value is there and the second one tests if the value is the same as what you expect it to be.