1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Tests for feeds_news feature.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Test Feed configuration.
|
10 |
|
|
*/
|
11 |
|
|
class FeedsExamplesFeedTestCase extends FeedsWebTestCase {
|
12 |
|
|
public static function getInfo() {
|
13 |
|
|
return array(
|
14 |
|
|
'name' => 'Feature: Feed',
|
15 |
|
|
'description' => 'Test "Feed" default configuration.',
|
16 |
|
|
'group' => 'Feeds',
|
17 |
|
|
'dependencies' => array('features', 'views'),
|
18 |
|
|
);
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
public function setUp() {
|
22 |
|
|
parent::setUp(array('features', 'views', 'feeds_news'));
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
/**
|
26 |
|
|
* Run tests.
|
27 |
|
|
*/
|
28 |
|
|
public function test() {
|
29 |
|
|
$nid = $this->createFeedNode('feed', NULL, '', 'feed');
|
30 |
|
|
|
31 |
|
|
// Assert menu tabs for feed nodes does not show up on non-feed nodes.
|
32 |
|
|
$this->drupalGet("node/{$nid}/feed-items");
|
33 |
|
|
$this->assertResponse(200);
|
34 |
|
|
$not_feed_node = $this->drupalCreateNode();
|
35 |
|
|
$this->drupalGet("node/{$not_feed_node->nid}/feed-items");
|
36 |
|
|
$this->assertResponse(404);
|
37 |
|
|
|
38 |
|
|
// Assert results.
|
39 |
|
|
$count = db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'")->fetchField();
|
40 |
|
|
$this->assertEqual($count, 10, 'Found the correct number of feed item nodes in database.');
|
41 |
|
|
|
42 |
|
|
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node'")->fetchField();
|
43 |
|
|
$this->assertEqual($count, 10, 'Found the correct number of records in feeds_item.');
|
44 |
|
|
|
45 |
|
|
$count = db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Open Atrium Translation Workflow: Two Way Translation Updates'")->fetchField();
|
46 |
|
|
$this->assertEqual($count, 1, 'Found title.');
|
47 |
|
|
$count = db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Week in DC Tech: October 5th Edition'")->fetchField();
|
48 |
|
|
$this->assertEqual($count, 1, 'Found title.');
|
49 |
|
|
$count = db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Integrating the Siteminder Access System in an Open Atrium-based Intranet'")->fetchField();
|
50 |
|
|
$this->assertEqual($count, 1, 'Found title.');
|
51 |
|
|
$count = db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Scaling the Open Atrium UI'")->fetchField();
|
52 |
|
|
$this->assertEqual($count, 1, 'Found title.');
|
53 |
|
|
|
54 |
|
|
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node' AND url = 'http://developmentseed.org/blog/2009/oct/06/open-atrium-translation-workflow-two-way-updating'")->fetchField();
|
55 |
|
|
$this->assertEqual($count, 1, 'Found feed_node_item record.');
|
56 |
|
|
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node' AND url = 'http://developmentseed.org/blog/2009/oct/05/week-dc-tech-october-5th-edition'")->fetchField();
|
57 |
|
|
$this->assertEqual($count, 1, 'Found feed_node_item record.');
|
58 |
|
|
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node' AND guid = '974 at http://developmentseed.org'")->fetchField();
|
59 |
|
|
$this->assertEqual($count, 1, 'Found feed_node_item record.');
|
60 |
|
|
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node' AND guid = '970 at http://developmentseed.org'")->fetchField();
|
61 |
|
|
$this->assertEqual($count, 1, 'Found feed_node_item record.');
|
62 |
|
|
|
63 |
|
|
// Remove all items
|
64 |
|
|
$this->drupalPost("node/$nid/delete-items", array(), 'Delete');
|
65 |
|
|
$this->assertText('Deleted 10 nodes');
|
66 |
|
|
|
67 |
|
|
// Import again.
|
68 |
|
|
$this->drupalPost("node/$nid/import", array(), 'Import');
|
69 |
|
|
$this->assertText('Created 10 nodes');
|
70 |
|
|
|
71 |
|
|
// Delete and assert all items gone.
|
72 |
|
|
$this->drupalPost("node/$nid/delete-items", array(), 'Delete');
|
73 |
|
|
|
74 |
|
|
$count = db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'")->fetchField();
|
75 |
|
|
$this->assertEqual($count, 0, 'Found the correct number of feed item nodes in database.');
|
76 |
|
|
|
77 |
|
|
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node'")->fetchField();
|
78 |
|
|
$this->assertEqual($count, 0, 'Found the correct number of records in feeds_item.');
|
79 |
|
|
|
80 |
|
|
// Create a batch of nodes.
|
81 |
|
|
$this->createFeedNodes('feed', 10, 'feed');
|
82 |
|
|
$count = db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'")->fetchField();
|
83 |
|
|
$this->assertEqual($count, 100, 'Imported 100 nodes.');
|
84 |
|
|
$count = db_query("SELECT COUNT(*) FROM {feeds_item} WHERE entity_type = 'node'")->fetchField();
|
85 |
|
|
$this->assertEqual($count, 100, 'Found 100 records in feeds_item.');
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
/**
|
90 |
|
|
* Test OPML import configuration.
|
91 |
|
|
*/
|
92 |
|
|
class FeedsExamplesOPMLTestCase extends FeedsWebTestCase {
|
93 |
|
|
|
94 |
|
|
public static function getInfo() {
|
95 |
|
|
return array(
|
96 |
|
|
'name' => 'Feature: OPML import',
|
97 |
|
|
'description' => 'Test "OPML import" default configuration.',
|
98 |
|
|
'group' => 'Feeds',
|
99 |
|
|
);
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
/**
|
103 |
|
|
* Enable feeds_news feature.
|
104 |
|
|
*/
|
105 |
|
|
public function setUp() {
|
106 |
|
|
parent::setUp(array('feeds_news'));
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
/**
|
110 |
|
|
* Run tests.
|
111 |
|
|
*/
|
112 |
|
|
public function test() {
|
113 |
|
|
|
114 |
|
|
// Import OPML and assert.
|
115 |
|
|
$file = $this->generateOPML();
|
116 |
|
|
$this->importFile('opml', $file);
|
117 |
|
|
$this->assertText('Created 3 nodes');
|
118 |
|
|
$count = db_query("SELECT COUNT(*) FROM {feeds_source}")->fetchField();
|
119 |
|
|
$this->assertEqual($count, 4, 'Found correct number of items.');
|
120 |
|
|
|
121 |
|
|
// Import a feed and then delete all items from it.
|
122 |
|
|
$this->drupalPost('node/1/import', array(), 'Import');
|
123 |
|
|
$this->assertText('Created 10 nodes');
|
124 |
|
|
$this->drupalPost('node/1/delete-items', array(), 'Delete');
|
125 |
|
|
$this->assertText('Deleted 10 nodes');
|
126 |
|
|
}
|
127 |
|
|
} |