public function BiblioKeywordWebTestCase::testBiblioGetKeywordByName in Bibliography Module 7
File
- tests/
BiblioKeywordWebTestCase.test, line 67
Class
- BiblioKeywordWebTestCase
- Biblio keyword web tests.
Code
public function testBiblioGetKeywordByName() {
$keyword = $this
->createKeyword();
// Load the term with the exact name.
$word = biblio_get_keyword_by_name($keyword['word']);
$this
->assertEqual($word->word, $keyword['word'], t('Keyword loaded using exact name.'));
// Load the term with space concatenated.
$word = biblio_get_keyword_by_name(' ' . $keyword['word'] . ' ');
$this
->assertEqual($word->word, trim(' ' . $keyword['word'] . ' '), t('Keyword loaded with extra whitespace.'));
// Load the term with name uppercased.
$word = biblio_get_keyword_by_name(strtoupper($keyword['word']));
$this
->assertEqual($word->word, $keyword['word'], t('Keyword loaded with uppercased name.'));
// Load the term with name lowercased.
$word = biblio_get_keyword_by_name(strtolower($keyword['word']));
$this
->assertEqual($word->word, $keyword['word'], t('Keyword loaded with lowercased name.'));
// Try to load an invalid term name.
$word = biblio_get_keyword_by_name('Banana');
$this
->assertFalse($word, t('Tried to load an invalid keyword'));
// Try to load the term using a substring of the name.
$word = biblio_get_keyword_by_name(drupal_substr($keyword['word'], 2));
$this
->assertFalse($word, t('Tried to load a keyword using a substring of the word'));
}