summaryrefslogtreecommitdiffstats
path: root/feeds_fast_news/feeds_fast_news.test
blob: bbf72843a8e0ca621387172ca5d82eecec8f247c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php

/**
 * @file
 * Tests for feeds_fast_news feature.
 */

// Require FeedsWebTestCase class definition.
require_once(dirname(__FILE__) .'/../tests/feeds.test.inc');

/**
 * Test Feed fast configuration.
 */
class FeedsExamplesFastFeedTestCase extends FeedsWebTestCase {

  /**
   * Set up test.
   */
  public function setUp() {
    parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler', 'features', 'feeds_fast_news', 'data', 'data_ui', 'views', 'views_ui');

    $this->drupalLogin(
      $this->drupalCreateUser(
        array(
          'administer feeds', 'administer nodes', 'administer data tables',
        )
      )
    );
  }

  /**
   * Describe this test.
   */
  public function getInfo() {
    return array(
      'name' => t('Feature: Fast feed'),
      'description' => t('Test "Fast feed" default configuration <strong>Requires Data, Features and Views.</strong>'),
      'group' => t('Feeds'),
    );
  }

  /**
   * Run tests.
   */
  public function test() {

    // Enable configuration and assert status.
    $this->drupalGet('admin/build/data');
    $this->assertText('feeds_data_feed_fast');
    $this->drupalGet('admin/content/data/view/feeds_data_feed_fast');
    $this->assertText('Fast feed');
    $this->assertText('There is no data in this table.');

    // Create feed node.
    $nid = $this->createFeedNode('feed_fast', NULL, '', 'feed_fast');
    $this->assertText('Created 10 items.');

    // Verify presence of aggregated items.
    $this->drupalGet('admin/content/data/view/feeds_data_feed_fast');
    $this->assertText('Open Atrium Translation Workflow: Two Way Translation Updates');
    $this->assertText('n a word, nothing. There has been a major improvement on this front. Now your translation');
    $this->assertLink('http://developmentseed.org/blog/2009/oct/06/open-atrium-translation-workflow-two-way-updating');

    // Delete and re import.
    $this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
    $this->assertText('All items have been deleted.');
    $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
    $this->assertEqual($count, 0, 'Found correct number of items.');

    $this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
    $this->assertText('There were no items to delete.');
    $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
    $this->assertEqual($count, 0, 'Found correct number of items.');

    $this->drupalPost('node/'. $nid .'/import', array(), 'Import');
    $this->assertText('Created 10 items.');
    $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
    $this->assertEqual($count, 10, 'Found correct number of items.');

    $this->drupalPost('node/'. $nid .'/import', array(), 'Import');
    $this->assertText('There are no new items.');
    $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
    $this->assertEqual($count, 10, 'Found correct number of items.');
  }
}