function SearchAdvancedSearchForm::testNodeType

Test using the search form with GET and POST queries. Test using the advanced search form to limit search to nodes of type "Basic page".

File

modules/search/search.test, line 350

Class

SearchAdvancedSearchForm
Indexes content and tests the advanced search form.

Code

function testNodeType() {
  $this->assertTrue($this->node->type == 'page', 'Node type is Basic page.');
  // Assert that the dummy title doesn't equal the real title.
  $dummy_title = 'Lorem ipsum';
  $this->assertNotEqual($dummy_title, $this->node->title, "Dummy title doesn't equal node title");
  // Search for the dummy title with a GET query.
  $this->drupalGet('search/node/' . $dummy_title);
  $this->assertNoText($this->node->title, 'Basic page node is not found with dummy title.');
  // Search for the title of the node with a GET query.
  $this->drupalGet('search/node/' . $this->node->title);
  $this->assertText($this->node->title, 'Basic page node is found with GET query.');
  // Search for the title of the node with a POST query.
  $edit = array(
    'or' => $this->node->title,
  );
  $this->drupalPost('search/node', $edit, t('Advanced search'));
  $this->assertText($this->node->title, 'Basic page node is found with POST query.');
  // Advanced search type option.
  $this->drupalPost('search/node', array_merge($edit, array(
    'type[page]' => 'page',
  )), t('Advanced search'));
  $this->assertText($this->node->title, 'Basic page node is found with POST query and type:page.');
  $this->drupalPost('search/node', array_merge($edit, array(
    'type[article]' => 'article',
  )), t('Advanced search'));
  $this->assertText('bike shed', 'Article node is not found with POST query and type:article.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.