You are here

function FeedAPINodeTestsCase::testKeepNodeSettingsAtUpdate in FeedAPI 6

Checks if the node updates by feedapi_node do not alter basic node options

File

feedapi_node/tests/feedapi_node.test, line 189

Class

FeedAPINodeTestsCase
Class for testing feedapi_node. It also tests FeedAPI and SimplePie parsers.

Code

function testKeepNodeSettingsAtUpdate() {
  $this
    ->create_type(array_pop($this
    ->get_parsers()));
  $settings = feedapi_get_settings($this->info->type);
  $this
    ->feedapi_user();
  $feed_url = $this
    ->testFileURL('test_feed.rss');
  $edit = array(
    'feedapi[feedapi_url]' => $feed_url,
  );
  $this
    ->drupalPost('node/add/' . $this->info->type, $edit, 'Save');
  $node = db_fetch_object(db_query("SELECT nid FROM {feedapi} WHERE url = '%s'", $feed_url));
  $this
    ->drupalGet("node/{$node->nid}/refresh");
  $notification = t("%new new item(s) were saved. %updated existing item(s) were updated.", array(
    "%new" => 10,
    "%updated" => 0,
  ));
  $notification = str_replace('<em>', '', $notification);
  $notification = str_replace('</em>', '', $notification);
  $this
    ->assertText($notification, 'The proper number of items were created');
  $title = 'xFgfsfdfsRDFGFes';
  $feed_url_new = $this
    ->testFileURL('test_feed_mod_title.rss');
  $sticky = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE sticky = 1"));
  $this
    ->assertTrue($sticky == 0, 'The sticky bit is off by default.');

  // Set the sticky to 1 on all the nodes item
  db_query("UPDATE {node} SET sticky = 1");

  // Invalidate current data and change the url
  db_query("UPDATE {feedapi} SET hash = '%s', url='%s' WHERE nid = %d", $this
    ->randomName(5), $feed_url_new, $node->nid);
  $this
    ->drupalGet("node/{$node->nid}/refresh");
  $not_sticky = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE sticky = 0"));
  $this
    ->assertTrue($not_sticky == 0, 'The sticky bit remained the same just as before the update');
  $this
    ->drupalGet('admin/content/node');
  $this
    ->assertText($title, 'The item node update was successful');
  $this
    ->drupalGet('/');
  $this
    ->assertText($title, 'The item node really appears on the first page.');
}