当前位置: 首页>>代码示例>>PHP>>正文


PHP HandlerBase::breakPhraseString方法代码示例

本文整理汇总了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);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:51,代码来源:HandlerTest.php


注:本文中的Drupal\views\Plugin\views\HandlerBase::breakPhraseString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。