input_filters.test in Twitter 7.4
Same filename and directory in other branches
Functional tests for the input filters of the twitter module.
File
tests/input_filters.testView 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(
'bypass node access',
'administer filters',
));
$this
->drupalLogin($this->privileged_user);
// Activate twitter input filters
$edit = array(
'filters[twitter_username][status]' => 1,
'filters[twitter_username][weight]' => 0,
'filters[twitter_hashtag][status]' => 1,
'filters[twitter_hashtag][weight]' => 1,
'filters[filter_url][weight]' => 2,
'filters[filter_html][weight]' => 3,
'filters[filter_autop][weight]' => 4,
'filters[filter_htmlcorrector][weight]' => 5,
);
$this
->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration'));
$this
->assertText(t('The text format Filtered HTML has been updated.'));
$this
->drupalGet('admin/config/content/formats/filtered_html');
$this
->assertFieldChecked('edit-filters-twitter-username-status', t('Twitter username input filter has been activated'));
$this
->assertFieldChecked('edit-filters-twitter-hashtag-status', 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[und][0][value]'] = 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('Basic 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
Name | Description |
---|---|
TwitterInputFilterTest | @file Functional tests for the input filters of the twitter module. |