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


PHP search_update_totals函数代码示例

本文整理汇总了PHP中search_update_totals函数的典型用法代码示例。如果您正苦于以下问题:PHP search_update_totals函数的具体用法?PHP search_update_totals怎么用?PHP search_update_totals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了search_update_totals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create and log in user.
     $test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration']);
     $this->drupalLogin($test_user);
     // Add a new language.
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Set up times to be applied to the English and Spanish translations of the
     // node create time, so that they are filtered in/out in the
     // search_date_query_alter test module.
     $created_time_en = new \DateTime('February 10 2016 10PM');
     $created_time_es = new \DateTime('March 19 2016 10PM');
     $default_format = filter_default_format();
     $node = $this->drupalCreateNode(['title' => 'Node EN', 'type' => 'page', 'body' => ['value' => $this->randomMachineName(32), 'format' => $default_format], 'langcode' => 'en', 'created' => $created_time_en->format('U')]);
     // Add Spanish translation to the node.
     $translation = $node->addTranslation('es', ['title' => 'Node ES']);
     $translation->body->value = $this->randomMachineName(32);
     $translation->created->value = $created_time_es->format('U');
     $node->save();
     // Update the index.
     $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
     $plugin->updateIndex();
     search_update_totals();
 }
开发者ID:systemick3,项目名称:systemick.co.uk,代码行数:25,代码来源:SearchDateIntervalTest.php

示例2: testExactQuery

 /**
  * Tests that the correct number of pager links are found for both keywords and phrases.
  */
 function testExactQuery()
 {
     // Login with sufficient privileges.
     $this->drupalLogin($this->drupalCreateUser(array('create page content', 'search content')));
     $settings = array('type' => 'page', 'title' => 'Simple Node');
     // Create nodes with exact phrase.
     for ($i = 0; $i <= 17; $i++) {
         $settings['body'] = array(array('value' => 'love pizza'));
         $this->drupalCreateNode($settings);
     }
     // Create nodes containing keywords.
     for ($i = 0; $i <= 17; $i++) {
         $settings['body'] = array(array('value' => 'love cheesy pizza'));
         $this->drupalCreateNode($settings);
     }
     // Update the search index.
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
     // Refresh variables after the treatment.
     $this->refreshVariables();
     // Test that the correct number of pager links are found for keyword search.
     $edit = array('keys' => 'love pizza');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertLinkByHref('page=1', 0, '2nd page link is found for keyword search.');
     $this->assertLinkByHref('page=2', 0, '3rd page link is found for keyword search.');
     $this->assertLinkByHref('page=3', 0, '4th page link is found for keyword search.');
     $this->assertNoLinkByHref('page=4', '5th page link is not found for keyword search.');
     // Test that the correct number of pager links are found for exact phrase search.
     $edit = array('keys' => '"love pizza"');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertLinkByHref('page=1', 0, '2nd page link is found for exact phrase search.');
     $this->assertNoLinkByHref('page=2', '3rd page link is not found for exact phrase search.');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:36,代码来源:SearchExactTest.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create searching user.
     $this->searchingUser = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'post comments', 'skip comment approval'));
     // Log in with sufficient privileges.
     $this->drupalLogin($this->searchingUser);
     // Add a comment field.
     $this->addDefaultCommentField('node', 'article');
     // Create initial nodes.
     $node_params = array('type' => 'article', 'body' => array(array('value' => 'SearchCommentToggleTestCase')));
     $this->searchableNodes['1 comment'] = $this->drupalCreateNode($node_params);
     $this->searchableNodes['0 comments'] = $this->drupalCreateNode($node_params);
     // Create a comment array
     $edit_comment = array();
     $edit_comment['subject[0][value]'] = $this->randomMachineName();
     $edit_comment['comment_body[0][value]'] = $this->randomMachineName();
     // Post comment to the test node with comment
     $this->drupalPostForm('comment/reply/node/' . $this->searchableNodes['1 comment']->id() . '/comment', $edit_comment, t('Save'));
     // First update the index. This does the initial processing.
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     // Then, run the shutdown function. Testing is a unique case where indexing
     // and searching has to happen in the same request, so running the shutdown
     // function manually is needed to finish the indexing process.
     search_update_totals();
 }
开发者ID:318io,项目名称:318-io,代码行数:26,代码来源:SearchCommentCountToggleTest.php

示例4: testPhraseSearchPunctuation

 /**
  * Tests that search works with punctuation and HTML entities.
  */
 function testPhraseSearchPunctuation()
 {
     $node = $this->drupalCreateNode(array('body' => array(array('value' => "The bunny's ears were fluffy."))));
     $node2 = $this->drupalCreateNode(array('body' => array(array('value' => 'Dignissim Aliquam &amp; Quieligo meus natu quae quia te. Damnum&copy; erat&mdash; neo pneum. Facilisi feugiat ibidem ratis.'))));
     // Update the search index.
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
     // Refresh variables after the treatment.
     $this->refreshVariables();
     // Submit a phrase wrapped in double quotes to include the punctuation.
     $edit = array('keys' => '"bunny\'s"');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertText($node->label());
     // Check if the author is linked correctly to the user profile page.
     $username = $node->getOwner()->getUsername();
     $this->assertLink($username);
     // Search for "&" and verify entities are not broken up in the output.
     $edit = array('keys' => '&');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertNoRaw('<strong>&</strong>amp;');
     $this->assertText('You must include at least one keyword');
     $edit = array('keys' => '&amp;');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertNoRaw('<strong>&</strong>amp;');
     $this->assertText('You must include at least one keyword');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:SearchNodePunctuationTest.php

示例5: setUp

 function setUp()
 {
     parent::setUp();
     // Create and login user.
     $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration'));
     $this->drupalLogin($test_user);
     // Add a new language.
     $language = new Language(array('id' => 'es', 'name' => 'Spanish'));
     language_save($language);
     // Make the body field translatable. The title is already translatable by
     // definition. The parent class has already created the article and page
     // content types.
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
     $field_storage->translatable = TRUE;
     $field_storage->save();
     // Create a few page nodes with multilingual body values.
     $default_format = filter_default_format();
     $nodes = array(array('title' => 'First node en', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'en'), array('title' => 'Second node this is the Spanish title', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'es'), array('title' => 'Third node en', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'en'));
     $this->searchable_nodes = array();
     foreach ($nodes as $setting) {
         $this->searchable_nodes[] = $this->drupalCreateNode($setting);
     }
     // Add English translation to the second node.
     $translation = $this->searchable_nodes[1]->addTranslation('en', array('title' => 'Second node en'));
     $translation->body->value = $this->randomMachineName(32);
     $this->searchable_nodes[1]->save();
     // Add Spanish translation to the third node.
     $translation = $this->searchable_nodes[2]->addTranslation('es', array('title' => 'Third node es'));
     $translation->body->value = $this->randomMachineName(32);
     $this->searchable_nodes[2]->save();
     // Update the index and then run the shutdown method.
     $plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
     $plugin->updateIndex();
     search_update_totals();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:35,代码来源:SearchLanguageTest.php

示例6: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create user.
     $this->searchingUser = $this->drupalCreateUser(array('search content', 'access user profiles'));
     // Create a node and update the search index.
     $this->node = $this->drupalCreateNode(['title' => 'bike shed shop']);
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:13,代码来源:SearchPageCacheTagsTest.php

示例7: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create a plugin instance.
     $this->nodeSearchPlugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
     // Create a node with a very simple body.
     $this->drupalCreateNode(array('body' => array(array('value' => 'tapir'))));
     // Update the search index.
     $this->nodeSearchPlugin->updateIndex();
     search_update_totals();
 }
开发者ID:318io,项目名称:318-io,代码行数:11,代码来源:SearchSetLocaleTest.php

示例8: testExactQuery

 /**
  * Tests that the correct number of pager links are found for both keywords and phrases.
  */
 function testExactQuery()
 {
     // Login with sufficient privileges.
     $user = $this->drupalCreateUser(array('create page content', 'search content'));
     $this->drupalLogin($user);
     $settings = array('type' => 'page', 'title' => 'Simple Node');
     // Create nodes with exact phrase.
     for ($i = 0; $i <= 17; $i++) {
         $settings['body'] = array(array('value' => 'love pizza'));
         $this->drupalCreateNode($settings);
     }
     // Create nodes containing keywords.
     for ($i = 0; $i <= 17; $i++) {
         $settings['body'] = array(array('value' => 'love cheesy pizza'));
         $this->drupalCreateNode($settings);
     }
     // Create another node and save it for later.
     $settings['body'] = array(array('value' => 'Druplicon'));
     $node = $this->drupalCreateNode($settings);
     // Update the search index.
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
     // Refresh variables after the treatment.
     $this->refreshVariables();
     // Test that the correct number of pager links are found for keyword search.
     $edit = array('keys' => 'love pizza');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertLinkByHref('page=1', 0, '2nd page link is found for keyword search.');
     $this->assertLinkByHref('page=2', 0, '3rd page link is found for keyword search.');
     $this->assertLinkByHref('page=3', 0, '4th page link is found for keyword search.');
     $this->assertNoLinkByHref('page=4', '5th page link is not found for keyword search.');
     // Test that the correct number of pager links are found for exact phrase search.
     $edit = array('keys' => '"love pizza"');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertLinkByHref('page=1', 0, '2nd page link is found for exact phrase search.');
     $this->assertNoLinkByHref('page=2', '3rd page link is not found for exact phrase search.');
     // Check that with post settings turned on the post information is displayed.
     $node_type_config = \Drupal::configFactory()->getEditable('node.type.page');
     $node_type_config->set('display_submitted', TRUE);
     $node_type_config->save();
     $edit = array('keys' => 'Druplicon');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertText($user->getUsername(), 'Basic page node displays author name when post settings are on.');
     $this->assertText(format_date($node->getChangedTime(), 'short'), 'Basic page node displays post date when post settings are on.');
     // Check that with post settings turned off the user and changed date
     // information is not displayed.
     $node_type_config->set('display_submitted', FALSE);
     $node_type_config->save();
     $edit = array('keys' => 'Druplicon');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertNoText($user->getUsername(), 'Basic page node does not display author name when post settings are off.');
     $this->assertNoText(format_date($node->getChangedTime(), 'short'), 'Basic page node does not display post date when post settings are off.');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:56,代码来源:SearchExactTest.php

示例9: setUp

 function setUp()
 {
     parent::setUp();
     // Create a user and a node, and update the search index.
     $test_user = $this->drupalCreateUser(array('access content', 'search content', 'administer nodes'));
     $this->drupalLogin($test_user);
     $this->node = $this->drupalCreateNode();
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
     // Set up a dummy initial count of times the form has been submitted.
     $this->submit_count = \Drupal::state()->get('search_embedded_form.submit_count');
     $this->refreshVariables();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:13,代码来源:SearchEmbedFormTest.php

示例10: testPhraseSearchPunctuation

 /**
  * Tests that search returns results with punctuation in the search phrase.
  */
 function testPhraseSearchPunctuation()
 {
     $node = $this->drupalCreateNode(array('body' => array(array('value' => "The bunny's ears were fluffy."))));
     // Update the search index.
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
     // Refresh variables after the treatment.
     $this->refreshVariables();
     // Submit a phrase wrapped in double quotes to include the punctuation.
     $edit = array('keys' => '"bunny\'s"');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertText($node->label());
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:16,代码来源:SearchNodePunctuationTest.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create and login user.
     $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes'));
     $this->drupalLogin($test_user);
     // Create initial node.
     $this->node = $this->drupalCreateNode();
     // First update the index. This does the initial processing.
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     // Then, run the shutdown function. Testing is a unique case where indexing
     // and searching has to happen in the same request, so running the shutdown
     // function manually is needed to finish the indexing process.
     search_update_totals();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:15,代码来源:SearchAdvancedSearchFormTest.php

示例12: _setup

 /**
  * Set up a small index of items to test against.
  */
 function _setup()
 {
     $this->config('search.settings')->set('index.minimum_word_size', 3)->save();
     for ($i = 1; $i <= 7; ++$i) {
         search_index(SEARCH_TYPE, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText($i));
     }
     for ($i = 1; $i <= 5; ++$i) {
         search_index(SEARCH_TYPE_2, $i + 7, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText2($i));
     }
     // No getText builder function for Japanese text; just a simple array.
     foreach (array(13 => '以呂波耳・ほへとち。リヌルヲ。', 14 => 'ドルーパルが大好きよ!', 15 => 'コーヒーとケーキ') as $i => $jpn) {
         search_index(SEARCH_TYPE_JPN, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $jpn);
     }
     search_update_totals();
 }
开发者ID:318io,项目名称:318-io,代码行数:18,代码来源:SearchMatchTest.php

示例13: setUp

 protected function setUp()
 {
     parent::setUp();
     // Login as a user that can create and search content.
     $this->searchUser = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks', 'access site reports'));
     $this->drupalLogin($this->searchUser);
     // Add a single piece of content and index it.
     $node = $this->drupalCreateNode();
     $this->searchNode = $node;
     // Link the node to itself to test that it's only indexed once. The content
     // also needs the word "pizza" so we can use it as the search keyword.
     $body_key = 'body[0][value]';
     $edit[$body_key] = \Drupal::l($node->label(), $node->urlInfo()) . ' pizza sandwich';
     $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
     // Enable the search block.
     $this->drupalPlaceBlock('search_form_block');
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:19,代码来源:SearchConfigSettingsFormTest.php

示例14: testQueryAlter

 /**
  * Tests that the query alter works.
  */
 function testQueryAlter()
 {
     // Login with sufficient privileges.
     $this->drupalLogin($this->drupalCreateUser(array('create page content', 'search content')));
     // Create a node and an article with the same keyword. The query alter
     // test module will alter the query so only articles should be returned.
     $data = array('type' => 'page', 'title' => 'test page', 'body' => array(array('value' => 'pizza')));
     $this->drupalCreateNode($data);
     $data['type'] = 'article';
     $data['title'] = 'test article';
     $this->drupalCreateNode($data);
     // Update the search index.
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
     // Search for the body keyword 'pizza'.
     $this->drupalPostForm('search/node', array('keys' => 'pizza'), t('Search'));
     // The article should be there but not the page.
     $this->assertText('article', 'Article is in search results');
     $this->assertNoText('page', 'Page is not in search results');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:23,代码来源:SearchQueryAlterTest.php

示例15: testPhraseSearchPunctuation

 /**
  * Tests that search returns results with diacritics in the search phrase.
  */
 function testPhraseSearchPunctuation()
 {
     $body_text = 'The Enricþment Center is cómmīŦŧęđ to the well BɆĬŇĜ of æll påŔťıçȉpǎǹţș. ';
     $body_text .= 'Also meklēt (see #731298)';
     $this->drupalCreateNode(array('body' => array(array('value' => $body_text))));
     // Update the search index.
     $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
     search_update_totals();
     // Refresh variables after the treatment.
     $this->refreshVariables();
     $edit = array('keys' => 'meklet');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertRaw('<strong>meklēt</strong>');
     $edit = array('keys' => 'meklēt');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertRaw('<strong>meklēt</strong>');
     $edit = array('keys' => 'cómmīŦŧęđ BɆĬŇĜ påŔťıçȉpǎǹţș');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertRaw('<strong>cómmīŦŧęđ</strong>');
     $this->assertRaw('<strong>BɆĬŇĜ</strong>');
     $this->assertRaw('<strong>påŔťıçȉpǎǹţș</strong>');
     $edit = array('keys' => 'committed being participants');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertRaw('<strong>cómmīŦŧęđ</strong>');
     $this->assertRaw('<strong>BɆĬŇĜ</strong>');
     $this->assertRaw('<strong>påŔťıçȉpǎǹţș</strong>');
     $edit = array('keys' => 'Enricþment');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertRaw('<strong>Enricþment</strong>');
     $edit = array('keys' => 'Enritchment');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertNoRaw('<strong>Enricþment</strong>');
     $edit = array('keys' => 'æll');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertRaw('<strong>æll</strong>');
     $edit = array('keys' => 'all');
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertNoRaw('<strong>æll</strong>');
 }
开发者ID:318io,项目名称:318-io,代码行数:42,代码来源:SearchNodeDiacriticsTest.php


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