You are here

input_filters.test in Twitter 6.3

Functional tests for the input filters of the twitter module.

File

tests/input_filters.test
View source
<?php

/**
 * @file
 * Functional tests for the input filters of the twitter module.
 */
class TwitterInputFilterTest extends DrupalWebTestCase {

  /*'
   * The getInfo() method provides information about the test.
   * In order for the test to be run, the getInfo() method needs
   * to be implemented.
   */
  public static function getInfo() {
    return array(
      'name' => t('Input filters'),
      'description' => t('Tests input filters provided by the Twitter module.'),
      'group' => t('Twitter'),
    );
  }

  /**
   * Prepares the testing environment
   */
  function setUp() {
    parent::setUp('twitter');
  }

  /**
   * Tests input filters
   */
  public function testInputFilters() {

    // Create user
    $this->privileged_user = $this
      ->drupalCreateUser(array(
      'administer nodes',
      'administer filters',
    ));
    $this
      ->drupalLogin($this->privileged_user);

    // Activate twitter input filters
    $edit = array(
      'filters[twitter/0]' => 1,
      'filters[twitter/1]' => 1,
    );
    $this
      ->drupalPost('admin/settings/filters/1', $edit, t('Save configuration'));
    $this
      ->assertText(t('The input format settings have been updated.'));
    $this
      ->drupalGet('admin/settings/filters/1');
    $this
      ->assertFieldChecked('edit-filters-twitter/0', t('Twitter username input filter has been activated'));
    $this
      ->assertFieldChecked('edit-filters-twitter/1', t('Twitter hashtag input filter has been activated'));

    // Create a page so we can evaluate the filters
    $search = '#drupal';
    $username = '@drupal';
    $edit = array();
    $edit['title'] = t('Test page');
    $edit['body'] = t('This is a search over #drupal tag. There is also a link ' . ' to a Twitter account here: @drupal.');
    $this
      ->drupalPost('node/add/page', $edit, t('Save'));
    $this
      ->assertText(t('Page @title has been created.', array(
      '@title' => $edit['title'],
    )));
    $this
      ->assertLink($search, 0, t('Twitter search input filter was created successfully.'));
    $this
      ->assertLink($username, 0, t('Twitter username input filter was created successfully.'));
  }

}

Classes

Namesort descending Description
TwitterInputFilterTest @file Functional tests for the input filters of the twitter module.