1 views_handlers.test ViewsHandlersTest::test_views_break_phrase_string()

Tests views_break_phrase_string function.

File

core/modules/views/tests/views_handlers.test, line 34
Definition of ViewsHandlersTest.

Class

ViewsHandlersTest
Tests abstract handlers of views.

Code

function test_views_break_phrase_string() {
  module_load_include('inc', 'views', 'includes/utility');
  $empty_class = new stdClass();
  $empty_class->operator = 'or';
  $empty_class->value = array();

  $null = NULL;
  // check defaults
  $this->assertEqual($empty_class, views_break_phrase_string('', $null));

  $handler = views_get_handler('node', 'title', 'argument');
  $this->assertEqual($handler, views_break_phrase_string('', $handler));

  // test ors
  $handler = views_break_phrase_string('word1 word2+word');
  $this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
  $this->assertEqual('or', $handler->operator);
  $handler = views_break_phrase_string('word1+word2+word');
  $this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
  $this->assertEqual('or', $handler->operator);
  $handler = views_break_phrase_string('word1 word2 word');
  $this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
  $this->assertEqual('or', $handler->operator);
  $handler = views_break_phrase_string('word-1+word-2+word');
  $this->assertEqualValue(array('word-1', 'word-2', 'word'), $handler);
  $this->assertEqual('or', $handler->operator);
  $handler = views_break_phrase_string('wõrd1+wõrd2+wõrd');
  $this->assertEqualValue(array('wõrd1', 'wõrd2', 'wõrd'), $handler);
  $this->assertEqual('or', $handler->operator);

  // test ands.
  $handler = views_break_phrase_string('word1,word2,word');
  $this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
  $this->assertEqual('and', $handler->operator);
  $handler = views_break_phrase_string('word1 word2,word');
  $this->assertEqualValue(array('word1 word2', 'word'), $handler);
  $this->assertEqual('and', $handler->operator);
  $handler = views_break_phrase_string('word1,word2 word');
  $this->assertEqualValue(array('word1', 'word2 word'), $handler);
  $this->assertEqual('and', $handler->operator);
  $handler = views_break_phrase_string('word-1,word-2,word');
  $this->assertEqualValue(array('word-1', 'word-2', 'word'), $handler);
  $this->assertEqual('and', $handler->operator);
  $handler = views_break_phrase_string('wõrd1,wõrd2,wõrd');
  $this->assertEqualValue(array('wõrd1', 'wõrd2', 'wõrd'), $handler);
  $this->assertEqual('and', $handler->operator);

  // test a single word
  $handler = views_break_phrase_string('word');
  $this->assertEqualValue(array('word'), $handler);
  $this->assertEqual('and', $handler->operator);
}