function SearchEmbedFormTest::testEmbeddedForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/search/src/Tests/SearchEmbedFormTest.php \Drupal\search\Tests\SearchEmbedFormTest::testEmbeddedForm()
Tests that the embedded form appears and can be submitted.
File
- core/
modules/ search/ src/ Tests/ SearchEmbedFormTest.php, line 58 - Contains \Drupal\search\Tests\SearchEmbedFormTest.
Class
- SearchEmbedFormTest
- Verifies that a form embedded in search results works.
Namespace
Drupal\search\TestsCode
function testEmbeddedForm() {
// First verify we can submit the form from the module's page.
$this
->drupalPostForm('search_embedded_form', array(
'name' => 'John',
), t('Send away'));
$this
->assertText(t('Test form was submitted'), 'Form message appears');
$count = \Drupal::state()
->get('search_embedded_form.submit_count');
$this
->assertEqual($this->submitCount + 1, $count, 'Form submission count is correct');
$this->submitCount = $count;
// Now verify that we can see and submit the form from the search results.
$this
->drupalGet('search/node', array(
'query' => array(
'keys' => $this->node
->label(),
),
));
$this
->assertText(t('Your name'), 'Form is visible');
$this
->drupalPostForm(NULL, array(
'name' => 'John',
), t('Send away'));
$this
->assertText(t('Test form was submitted'), 'Form message appears');
$count = \Drupal::state()
->get('search_embedded_form.submit_count');
$this
->assertEqual($this->submitCount + 1, $count, 'Form submission count is correct');
$this->submitCount = $count;
// Now verify that if we submit the search form, it doesn't count as
// our form being submitted.
$this
->drupalPostForm('search', array(
'keys' => 'foo',
), t('Search'));
$this
->assertNoText(t('Test form was submitted'), 'Form message does not appear');
$count = \Drupal::state()
->get('search_embedded_form.submit_count');
$this
->assertEqual($this->submitCount, $count, 'Form submission count is correct');
$this->submitCount = $count;
}