function ViewsHandlersTest::test_views_break_phrase_string

Tests views_break_phrase_string function.

File

tests/views_handlers.test, line 47

Class

ViewsHandlersTest
Tests abstract handlers of views.

Code

public function test_views_break_phrase_string() {
    $empty_stdclass = new stdClass();
    $empty_stdclass->operator = 'or';
    $empty_stdclass->value = array();
    $null = NULL;
    // Check defaults.
    $this->assertEqual($empty_stdclass, 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);
}