You are here

function SearchByPageAttachUploadsTest::testSearchAttach in Search by Page 6

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

2 methods override SearchByPageAttachUploadsTest::testSearchAttach()
SearchByPageAttachCCKTest::testSearchAttach in tests/search_by_page.test
Tests that attachments are searched, and display options.
SearchbyPageAttachUploads2Test::testSearchAttach in tests/search_by_page.test
Tests that attachments are searched, and permissions.

File

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

Class

SearchByPageAttachUploadsTest
Functionality test 1 for Search by Page Attachments with Uploads module.

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

  // Verify that the upper-case extension was also found.
  $this
    ->assertText('attach5.TXT', "File name shown for upper-case extension");

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