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(); }
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(); }
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(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create user. $this->searchingUser = $this->drupalCreateUser(array('search content', 'access user profiles', 'use advanced search')); $this->drupalPlaceBlock('local_tasks_block'); }
protected function setUp() { parent::setUp(); // Create a plugin instance. $this->nodeSearch = entity_load('search_page', 'node_search'); // Login with sufficient privileges. $this->drupalLogin($this->drupalCreateUser(array('post comments', 'skip comment approval', 'create page content', 'administer search'))); }
protected function setUp() { parent::setUp(); // Create searching user. $this->searchingUser = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); // Login with sufficient privileges. $this->drupalLogin($this->searchingUser); }
/** * {@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->node->setOwner($this->searchingUser); $this->node->save(); $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); search_update_totals(); }
protected function setUp() { parent::setUp(); $full_html_format = entity_create('filter_format', array('format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, 'filters' => array())); $full_html_format->save(); // Create and log in an administrative user having access to the Full HTML // text format. $permissions = array('administer filters', $full_html_format->getPermissionName(), 'administer permissions', 'create page content', 'post comments', 'skip comment approval', 'access comments'); $this->adminUser = $this->drupalCreateUser($permissions); $this->drupalLogin($this->adminUser); // Add a comment field. $this->addDefaultCommentField('node', 'article'); }
protected function setUp() { parent::setUp(); $this->testUser = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); $this->drupalLogin($this->testUser); foreach ($this->numbers as $doc => $num) { $info = array('body' => array(array('value' => $num)), 'type' => 'page', 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'title' => $doc . ' number'); $this->nodes[$doc] = $this->drupalCreateNode($info); } // Run cron to ensure the content is indexed. $this->cronRun(); $this->drupalGet('admin/reports/dblog'); $this->assertText(t('Cron run completed'), 'Log shows cron run completed'); }
protected function setUp() { parent::setUp(); $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); $this->drupalLogin($this->test_user); // Create content with various numbers in it. // Note: 50 characters is the current limit of the search index's word // field. $this->numbers = array('ISBN' => '978-0446365383', 'UPC' => '036000 291452', 'EAN bar code' => '5901234123457', 'negative' => '-123456.7890', 'quoted negative' => '"-123456.7890"', 'leading zero' => '0777777777', 'tiny' => '111', 'small' => '22222222222222', 'medium' => '333333333333333333333333333', 'large' => '444444444444444444444444444444444444444', 'gigantic' => '5555555555555555555555555555555555555555555555555', 'over fifty characters' => '666666666666666666666666666666666666666666666666666666666666', 'date' => '01/02/2009', 'commas' => '987,654,321'); foreach ($this->numbers as $doc => $num) { $info = array('body' => array(array('value' => $num)), 'type' => 'page', 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'title' => $doc . ' number'); $this->nodes[$doc] = $this->drupalCreateNode($info); } // Run cron to ensure the content is indexed. $this->cronRun(); $this->drupalGet('admin/reports/dblog'); $this->assertText(t('Cron run completed'), 'Log shows cron run completed'); }
protected function setUp() { parent::setUp(); // Create a user who can administer search, do searches, see the status // report, and administer cron. Log in. $user = $this->drupalCreateUser(array('administer search', 'search content', 'use advanced search', 'access content', 'access site reports', 'administer site configuration')); $this->drupalLogin($user); // Make sure that auto-cron is disabled. $this->config('system.cron')->set('threshold.autorun', 0)->save(); // Set up the search plugin. $this->plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); // Check indexing counts before adding any nodes. $this->assertIndexCounts(0, 0, 'before adding nodes'); $this->assertDatabaseCounts(0, 0, 'before adding nodes'); // Add two new languages. ConfigurableLanguage::createFromLangcode('hu')->save(); ConfigurableLanguage::createFromLangcode('sv')->save(); // 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->setTranslatable(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 English title', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'en'), array('title' => 'Third node en', 'type' => 'page', 'body' => array(array('value' => $this->randomMachineName(32), 'format' => $default_format)), 'langcode' => 'en'), array(), array(), array(), array(), array()); $this->searchableNodes = array(); foreach ($nodes as $setting) { $this->searchableNodes[] = $this->drupalCreateNode($setting); } // Add a single translation to the second node. $translation = $this->searchableNodes[1]->addTranslation('hu', array('title' => 'Second node hu')); $translation->body->value = $this->randomMachineName(32); $this->searchableNodes[1]->save(); // Add two translations to the third node. $translation = $this->searchableNodes[2]->addTranslation('hu', array('title' => 'Third node this is the Hungarian title')); $translation->body->value = $this->randomMachineName(32); $translation = $this->searchableNodes[2]->addTranslation('sv', array('title' => 'Third node sv')); $translation->body->value = $this->randomMachineName(32); $this->searchableNodes[2]->save(); // Verify that we have 8 nodes left to do. $this->assertIndexCounts(8, 8, 'before updating the search index'); $this->assertDatabaseCounts(0, 0, 'before updating the search index'); }
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'); }
function setUp() { parent::setUp(); $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); $this->drupalLogin($this->test_user); // Define a group of numbers that should all match each other -- // numbers with internal punctuation should match each other, as well // as numbers with and without leading zeros and leading/trailing // . and -. $this->numbers = array('123456789', '12/34/56789', '12.3456789', '12-34-56789', '123,456,789', '-123456789', '0123456789'); foreach ($this->numbers as $num) { $info = array('body' => array(array('value' => $num)), 'type' => 'page', 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->nodes[] = $this->drupalCreateNode($info); } // Run cron to ensure the content is indexed. $this->cronRun(); $this->drupalGet('admin/reports/dblog'); $this->assertText(t('Cron run completed'), 'Log shows cron run completed'); }
protected function setUp() { parent::setUp(); // Create user. $this->searching_user = $this->drupalCreateUser(array('search content', 'access user profiles', 'use advanced search')); }
public function setUp() { parent::setUp(); // Create a plugin instance. $this->nodeSearch = entity_load('search_page', 'node_search'); }