You are here

function SearchByPageAttachTest::testSearchAttach in Search by Page 7

Tests that attachments are searched, and permissions, and display options.

3 methods override SearchByPageAttachTest::testSearchAttach()
SearchbyPageAttach2Test::testSearchAttach in tests/search_by_page.test
Tests that attachments are searched, and permissions.
SearchbyPageAttachNotReadable::testSearchAttach in tests/search_by_page.test
Tests that attachments with unreadable text are handled OK.
SearchbyPageAttachReindexTest::testSearchAttach in tests/search_by_page.test
Tests that attachments are reindexed when the node changes.

File

tests/search_by_page.test, line 2126
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageAttachTest
Functionality test 1 for Search by Page Attachments.

Code

function testSearchAttach() {
  $this
    ->drupalLogin($this->superuser);
  $search_path = $this->envinfo2['page_path'];

  // Search for the word 'flowers'
  $this
    ->drupalPost($search_path, array(
    'keys' => 'flowers',
  ), t('Search pages'));

  // Should find just the one listed attachment
  $this
    ->assertText('flowers', "Flowers appears in search results for flowers");
  $this
    ->assertText('daisy', "First attachment was found");
  $this
    ->assertNoText('snapdragon', "Second attachment was not found");
  $this
    ->assertNoText('dahlia', "Third attachment was not found");

  // Non-privileged user
  $this
    ->drupalLogin($this->noprivuser);

  // Search for the word 'flowers'
  $this
    ->drupalPost($search_path, array(
    'keys' => 'flowers',
  ), t('Search pages'));

  // Should find no attachments
  $this
    ->assertNoText('flowers', "Flowers does not appear in search results for flowers");
  $this
    ->assertNoText('daisy', "First attachment was not found");
  $this
    ->assertNoText('snapdragon', "Second attachment was not found");
  $this
    ->assertNoText('dahlia', "Third attachment was not found");

  // Display options section...
  $this
    ->drupalLogin($this->superuser);

  // Set display options so it should have attachment file name only
  $this
    ->setDisplayOptions(FALSE, " bush ", FALSE, $this->envid2);

  // Search for the word 'flowers'
  $this
    ->drupalPost($search_path, array(
    'keys' => 'flowers',
  ), t('Search pages'));

  // Verify display options
  $this
    ->assertText('attach1.txt', "File name shown");
  $this
    ->assertNoText('foods', "Page title not shown");
  $this
    ->assertNoText('bush', "Separator not shown");
  $this
    ->assertNoText('lonely', "Description not shown");

  // Also verify that the upper-case extension was found.
  $this
    ->assertText('attach5.TXT', "Upper case extension file name shown");

  // Set display options so it should have page title shown with separator
  $this
    ->setDisplayOptions(TRUE, " bush ", FALSE, $this->envid2);

  // Search for the word 'flowers'
  $this
    ->drupalPost($search_path, array(
    'keys' => 'flowers',
  ), t('Search pages'));

  // Verify display options
  $this
    ->assertText('attach1.txt', "File name shown");
  $this
    ->assertText('foods', "Page title shown");
  $this
    ->assertText('bush', "Separator shown");
  $this
    ->assertNoText('lonely', "Description not shown");

  // Set display options so it should have description, no page title
  $this
    ->setDisplayOptions(FALSE, " bush ", TRUE, $this->envid2);

  // Search for the word 'flowers'
  $this
    ->drupalPost($search_path, array(
    'keys' => 'flowers',
  ), t('Search pages'));

  // Verify display options
  $this
    ->assertNoText('attach1.txt', "File name not shown");
  $this
    ->assertNoText('foods', "Page title not shown");
  $this
    ->assertNoText('bush', "Separator not shown");
  $this
    ->assertText('lonely', "Description shown");
}