本文整理汇总了PHP中Drupal\views\Plugin\views\HandlerBase::breakPhraseString方法的典型用法代码示例。如果您正苦于以下问题:PHP HandlerBase::breakPhraseString方法的具体用法?PHP HandlerBase::breakPhraseString怎么用?PHP HandlerBase::breakPhraseString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Plugin\views\HandlerBase
的用法示例。
在下文中一共展示了HandlerBase::breakPhraseString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBreakPhraseString
/**
* Tests the breakPhraseString() method.
*/
function testBreakPhraseString()
{
$empty_stdclass = new \stdClass();
$empty_stdclass->operator = 'or';
$empty_stdclass->value = array();
// check defaults
$null = NULL;
$this->assertEqual($empty_stdclass, HandlerBase::breakPhraseString('', $null));
$item = array('table' => 'node', 'field' => 'title');
$handler = $this->container->get('plugin.manager.views.argument')->getHandler($item);
$this->assertEqual($handler, HandlerBase::breakPhraseString('', $handler), 'The breakPhraseString() method works correctly.');
// test ors
$handler = HandlerBase::breakPhraseString('word1 word2+word');
$this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
$this->assertEqual('or', $handler->operator);
$handler = HandlerBase::breakPhraseString('word1+word2+word');
$this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
$this->assertEqual('or', $handler->operator);
$handler = HandlerBase::breakPhraseString('word1 word2 word');
$this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
$this->assertEqual('or', $handler->operator);
$handler = HandlerBase::breakPhraseString('word-1+word-2+word');
$this->assertEqualValue(array('word-1', 'word-2', 'word'), $handler);
$this->assertEqual('or', $handler->operator);
$handler = HandlerBase::breakPhraseString('wõrd1+wõrd2+wõrd');
$this->assertEqualValue(array('wõrd1', 'wõrd2', 'wõrd'), $handler);
$this->assertEqual('or', $handler->operator);
// test ands.
$handler = HandlerBase::breakPhraseString('word1,word2,word');
$this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
$this->assertEqual('and', $handler->operator);
$handler = HandlerBase::breakPhraseString('word1 word2,word');
$this->assertEqualValue(array('word1 word2', 'word'), $handler);
$this->assertEqual('and', $handler->operator);
$handler = HandlerBase::breakPhraseString('word1,word2 word');
$this->assertEqualValue(array('word1', 'word2 word'), $handler);
$this->assertEqual('and', $handler->operator);
$handler = HandlerBase::breakPhraseString('word-1,word-2,word');
$this->assertEqualValue(array('word-1', 'word-2', 'word'), $handler);
$this->assertEqual('and', $handler->operator);
$handler = HandlerBase::breakPhraseString('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 = HandlerBase::breakPhraseString('word');
$this->assertEqualValue(array('word'), $handler);
$this->assertEqual('and', $handler->operator);
}