core.test 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @file
  4. * Functional tests for the twitter Module.
  5. */
  6. class TwitterTest extends DrupalWebTestCase {
  7. /*'
  8. * The getInfo() method provides information about the test.
  9. * In order for the test to be run, the getInfo() method needs
  10. * to be implemented.
  11. */
  12. public static function getInfo() {
  13. return array(
  14. 'name' => t('Main functionality'),
  15. 'description' => t('Tests main module functionality.'),
  16. 'group' => t('Twitter'),
  17. );
  18. }
  19. /**
  20. * Prepares the testing environment
  21. */
  22. function setUp() {
  23. parent::setUp('twitter', 'views');
  24. }
  25. /**
  26. * Tests account addition without Oauth module activated
  27. */
  28. public function testAccountAdditionNoOauth() {
  29. // Create user
  30. $this->user = $this->drupalCreateUser(array(
  31. 'add twitter accounts',
  32. 'import own tweets',
  33. ));
  34. $this->drupalLogin($this->user);
  35. // Add a Twitter account
  36. $edit = array(
  37. 'screen_name' => 'drupal',
  38. );
  39. $this->drupalPost('user/' . $this->user->uid . '/edit/twitter',
  40. $edit, t('Add account'));
  41. $this->assertLink('drupal', 0,
  42. t('Twitter account was added successfully'));
  43. // Load tweets
  44. twitter_cron();
  45. $this->drupalGet('user/' . $this->user->uid . '/tweets');
  46. $elements = $this->xpath('//div[contains(@class, "view-tweets")]/div/table');
  47. $this->assertTrue(count($elements), 'Tweets were loaded successfully.');
  48. // Delete the Twitter account
  49. $edit = array(
  50. 'accounts[0][delete]' => 1,
  51. );
  52. $this->drupalPost('user/' . $this->user->uid . '/edit/twitter',
  53. $edit, t('Save changes'));
  54. $this->assertText(t('The Twitter account was deleted.'));
  55. }
  56. }