first import
This commit is contained in:
62
sites/all/modules/twitter/tests/core.test
Normal file
62
sites/all/modules/twitter/tests/core.test
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functional tests for the twitter Module.
|
||||
*/
|
||||
|
||||
class TwitterTest 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('Main functionality'),
|
||||
'description' => t('Tests main module functionality.'),
|
||||
'group' => t('Twitter'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the testing environment
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp('twitter', 'views');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests account addition without Oauth module activated
|
||||
*/
|
||||
public function testAccountAdditionNoOauth() {
|
||||
// Create user
|
||||
$this->user = $this->drupalCreateUser(array(
|
||||
'add twitter accounts',
|
||||
'import own tweets',
|
||||
));
|
||||
$this->drupalLogin($this->user);
|
||||
|
||||
// Add a Twitter account
|
||||
$edit = array(
|
||||
'screen_name' => 'drupal',
|
||||
);
|
||||
$this->drupalPost('user/' . $this->user->uid . '/edit/twitter',
|
||||
$edit, t('Add account'));
|
||||
$this->assertLink('drupal', 0,
|
||||
t('Twitter account was added successfully'));
|
||||
|
||||
// Load tweets
|
||||
twitter_cron();
|
||||
$this->drupalGet('user/' . $this->user->uid . '/tweets');
|
||||
$elements = $this->xpath('//div[contains(@class, "view-tweets")]/div/table');
|
||||
$this->assertTrue(count($elements), 'Tweets were loaded successfully.');
|
||||
// Delete the Twitter account
|
||||
$edit = array(
|
||||
'accounts[0][delete]' => 1,
|
||||
);
|
||||
$this->drupalPost('user/' . $this->user->uid . '/edit/twitter',
|
||||
$edit, t('Save changes'));
|
||||
$this->assertText(t('The Twitter account was deleted.'));
|
||||
}
|
||||
}
|
71
sites/all/modules/twitter/tests/input_filters.test
Normal file
71
sites/all/modules/twitter/tests/input_filters.test
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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.'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user