function SearchEmbedForm::testEmbeddedForm

Tests that the embedded form appears and can be submitted.

File

drupal/modules/search/search.test, line 1907
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
    ->drupalPost('search_embedded_form', array(
    'name' => 'John',
  ), t('Send away'));
  $this
    ->assertText(t('Test form was submitted'), 'Form message appears');
  $count = variable_get('search_embedded_form_submitted', 0);
  $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
    ->drupalGet('search/node/' . $this->node->title);
  $this
    ->assertText(t('Your name'), 'Form is visible');
  $this
    ->drupalPost('search/node/' . $this->node->title, array(
    'name' => 'John',
  ), t('Send away'));
  $this
    ->assertText(t('Test form was submitted'), 'Form message appears');
  $count = variable_get('search_embedded_form_submitted', 0);
  $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
    ->drupalPost('search', array(
    'keys' => 'foo',
  ), t('Search'));
  $this
    ->assertNoText(t('Test form was submitted'), 'Form message does not appear');
  $count = variable_get('search_embedded_form_submitted', 0);
  $this
    ->assertEqual($this->submit_count, $count, 'Form submission count is correct');
  $this->submit_count = $count;
}