Hash: refactor unit tests

This commit is contained in:
terrafrost 2014-08-10 11:52:31 -05:00
parent 4fa96e384c
commit fb2ecc6c18
2 changed files with 20 additions and 24 deletions

View File

@ -12,21 +12,19 @@ class Unit_Crypt_Hash_SHA256_96Test extends Unit_Crypt_Hash_SHA256Test
return new Crypt_Hash('sha256-96');
}
static public function hashData()
/**
* @dataProvider hashData()
*/
public function testHash($message, $longResult)
{
$tests = parent::hashData();
foreach ($tests as &$test) {
$test[1] = substr($test[1], 0, 24);
}
return $tests;
parent::testHash($message, substr($longResult, 0, 24));
}
static public function hmacData()
/**
* @dataProvider hmacData()
*/
public function testHMAC($key, $message, $longResult)
{
$tests = parent::hmacData();
foreach ($tests as &$test) {
$test[2] = substr($test[2], 0, 24);
}
return $tests;
$this->assertHMACsTo($this->getInstance(), $key, $message, substr($longResult, 0, 24));
}
}

View File

@ -12,21 +12,19 @@ class Unit_Crypt_Hash_SHA512_96Test extends Unit_Crypt_Hash_SHA512Test
return new Crypt_Hash('sha512-96');
}
static public function hashData()
/**
* @dataProvider hashData()
*/
public function testHash($message, $longResult)
{
$tests = parent::hashData();
foreach ($tests as &$test) {
$test[1] = substr($test[1], 0, 24);
}
return $tests;
parent::testHash($message, substr($longResult, 0, 24));
}
static public function hmacData()
/**
* @dataProvider hmacData()
*/
public function testHMAC($key, $message, $longResult)
{
$tests = parent::hmacData();
foreach ($tests as &$test) {
$test[2] = substr($test[2], 0, 24);
}
return $tests;
$this->assertHMACsTo($this->getInstance(), $key, $message, substr($longResult, 0, 24));
}
}