You are here

public function BiblioKeywordWebTestCase::testBiblioExplodeKeywords in Bibliography Module 7

File

tests/BiblioKeywordWebTestCase.test, line 144

Class

BiblioKeywordWebTestCase
Biblio keyword web tests.

Code

public function testBiblioExplodeKeywords() {
  $keywords = array();
  $exploded = array();
  $words = array();
  $sep = variable_get('biblio_keyword_sep', ',');
  $wrong_sep = $sep == ',' ? ';' : ',';
  for ($i = 0; $i < 4; $i++) {
    $words[] = $this
      ->randomName();
  }
  $string = implode($sep, $words);
  $exploded = biblio_explode_keywords($string);
  $this
    ->assertIdentical($words, $exploded, 'Exploded keyword string with correct separator');
  $string = implode($wrong_sep, $words);
  $exploded = biblio_explode_keywords($string);
  $this
    ->assertNotIdentical($words, $exploded, 'Tried to explode keyword string with incorrect separator');
  $words[] = '"word1' . $sep . ' word2"';
  $string = implode($sep, $words);
  $exploded = biblio_explode_keywords($string);

  // Strip the quotes becuase that's the way it comes back.
  $words[4] = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\\1', $words[4])));
  $this
    ->assertEqual($words, $exploded, "Exploded a keyword string which contains and escaped separator");
}