You are here

public function TwitterTest::testAccountAdditionNoOauth in Twitter 7.5

Same name and namespace in other branches
  1. 6.5 tests/core.test \TwitterTest::testAccountAdditionNoOauth()
  2. 6.4 tests/core.test \TwitterTest::testAccountAdditionNoOauth()
  3. 7.6 tests/core.test \TwitterTest::testAccountAdditionNoOauth()
  4. 7.3 tests/core.test \TwitterTest::testAccountAdditionNoOauth()
  5. 7.4 tests/core.test \TwitterTest::testAccountAdditionNoOauth()

Tests account addition without Oauth module activated.

File

tests/core.test, line 31
Functional tests for the Twitter module.

Class

TwitterTest
@file Functional tests for the Twitter module.

Code

public function testAccountAdditionNoOauth() {

  // Create a user.
  $this->user = $this
    ->drupalCreateUser(array(
    'add twitter accounts',
    'add authenticated twitter accounts',
  ));
  $this
    ->drupalLogin($this->user);

  // The path to the user account's Twitter page.
  $url = 'user/' . $this->user->uid . '/edit/twitter';

  // Before the global account is created, verify that accounts may not be
  // added yet.
  variable_set('twitter_consumer_key', '');
  variable_set('twitter_consumer_secret', '');
  $this
    ->drupalGet($url);
  $this
    ->assertText(t('You need to authenticate at least one Twitter account in order to use the Twitter API.'));

  // Set some mock auth strings.
  variable_set('twitter_consumer_key', 'twitter_consumer_key');
  variable_set('twitter_consumer_secret', 'twitter_consumer_secret');

  // Verify the Twitter user page loads correctly.
  $this
    ->drupalGet($url);
  $this
    ->assertText(t('Add Twitter accounts'));

  // Verify the "add account" button exists after providing mock auth strings.
  $this
    ->drupalGet($url);
  $this
    ->assertText(t('Authenticated accounts can post, sign in and pull mentions'));

  /**
   * Need to fix the twitter_mock system so that these work again.
   */

  // // Add an account.
  // $edit = array(
  //   'screen_name' => 'drupal',
  // );
  // $this->drupalPost($url, $edit, t('Go to Twitter to add an authenticated 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.
  // $url = 'user/' . $this->user->uid . '/edit/twitter';
  // $edit = array(
  //   'accounts[0][delete]' => 1,
  // );
  // $this->drupalPost($url, $edit, t('Save changes'));
  // $this->assertText(t('The Twitter account was deleted.'));
}