public function AcquiaSearchUnitTestCase::testDerivedKey in Acquia Connector 7.2
Same name and namespace in other branches
- 7.3 acquia_search/tests/acquia_search.test \AcquiaSearchUnitTestCase::testDerivedKey()
Tests derived key generation.
File
- acquia_search/
tests/ acquia_search.test, line 47 - Tests for the Acquia Search module.
Class
- AcquiaSearchUnitTestCase
- Unit tests of the functionality of the Acquia Search module.
Code
public function testDerivedKey() {
// Mimic the hashing code in the API function.
$derivation_string = $this->id . 'solr' . $this->salt;
// str_pad extends the string with the same string in this case
// until it has filled 80 chars.
$derived_key = hash_hmac('sha1', str_pad($derivation_string, 80, $derivation_string), $this->key);
// $this->derivedKey is generated from the API function.
// @see setUp()
$this
->assertEqual($this->derivedKey, $derived_key, t('Derived key API function generates the expected hash.'), 'Acquia Search');
}