You are here

function SearchByPageAttachCCKTest::testSearchAttach in Search by Page 6

Tests that attachments are searched, and display options.

Overrides SearchByPageAttachUploadsTest::testSearchAttach

3 methods override SearchByPageAttachCCKTest::testSearchAttach()
SearchbyPageAttachCCK2Test::testSearchAttach in tests/search_by_page.test
Tests that attachments are searched.
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 2301
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageAttachCCKTest
Functionality test 1 for Search by Page Attachments with CCK module.

Code

function testSearchAttach() {
  $this
    ->drupalLogin($this->superuser);
  $search_path = $this->envinfo1['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");

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

  // 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");

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

  // 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->envid1);

  // 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");
}