core.test in Twitter 7.4
Same filename and directory in other branches
Functional tests for the twitter Module.
File
tests/core.testView source
<?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'),
      'description' => t('Tests main module features such as adding accounts or loading tweets.'),
      'group' => t('Twitter'),
    );
  }
  /**
   * Prepares the testing environment
   */
  function setUp() {
    parent::setUp('twitter', 'views', 'twitter_mock');
  }
  /**
   * 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.'));
  }
}Classes
| 
            Name | 
                  Description | 
|---|---|
| TwitterTest | @file Functional tests for the twitter Module. |