1 search.test SearchEmbedForm::testEmbeddedForm()

Tests that the embedded form appears and can be submitted.

File

core/modules/search/tests/search.test, line 1898
Tests for search.module.

Class

SearchEmbedForm
Tests that we can embed a form in search results and submit it.

Code

function testEmbeddedForm() {
  // First verify we can submit the form from the module's page.
  $this->backdropPost('search_embedded_form', 
  array('name' => 'John'), 'Send away');
  $this->assertText('Test form was submitted', 'Form message appears');
  $count = config_get('search.settings', 'search_embedded_form_submitted');
  $this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
  $this->submit_count = $count;

  // Now verify that we can see and submit the form from the search results.
  $this->backdropGet('search/node/' . $this->node->title);
  $this->assertText('Your name', 'Form is visible');
  $this->backdropPost('search/node/' . $this->node->title, 
  array('name' => 'John'), 'Send away');
  $this->assertText('Test form was submitted', 'Form message appears');
  $count = config_get('search.settings', 'search_embedded_form_submitted');
  $this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
  $this->submit_count = $count;

  // Now verify that if we submit the search form, it doesn't count as
  // our form being submitted.
  $this->backdropPost('search', 
  array('keys' => 'foo'), 
  t('Search'));
  $this->assertNoText(t('Test form was submitted'), 'Form message does not appear');
  $count = config_get('search.settings', 'search_embedded_form_submitted');
  $this->assertEqual($this->submit_count, $count, 'Form submission count is correct');
  $this->submit_count = $count;
}