You are here

function FeedAPIErrorTestsCase::testFeedAdd in FeedAPI 6

Feed add form.

File

tests/feedapi_error.test, line 39

Class

FeedAPIErrorTestsCase
Class for testing FeedAPI error-proofness. Various tests for invalid input and misconfiguration handling.

Code

function testFeedAdd() {
  $this
    ->create_type(array_pop($this
    ->get_parsers()));
  $this
    ->feedapi_user(TRUE);
  $feed_urls = array();
  $feed_urls[0] = $this
    ->randomName();
  $edit = array(
    'feedapi[feedapi_url]' => $feed_urls[0],
    'feedapi[refresh_time]' => FEEDAPI_CRON_ALWAYS_REFRESH,
  );
  $this
    ->drupalPost('node/add/' . $this->info->type, $edit, 'Save');
  $this
    ->assertText(t('Title could not be retrieved from feed.'), 'Invalid URL results in correct warning.');
  $feed_urls[1] = 'http://validbutnonexisting' . $this
    ->randomName(25) . '.com/foo';
  $edit = array(
    'feedapi[feedapi_url]' => $feed_urls[1],
    'feedapi[refresh_time]' => FEEDAPI_CRON_ALWAYS_REFRESH,
  );
  $this
    ->drupalPost('node/add/' . $this->info->type, $edit, 'Save');
  $this
    ->assertText(t('Title could not be retrieved from feed.'), 'Non-existing URL results in correct warning.');
  $this
    ->drupalGet('admin/build/menu-customize/navigation');
  $this
    ->drupalGet('admin/content/node-type/' . $this->info->type);
  $this
    ->assertText('Is a feed content type');

  // Turn off all the parsers for that feed
  $edit = array(
    'feedapi[parsers][parser_simplepie][enabled]' => FALSE,
    'feedapi[parsers][parser_common_syndication][enabled]' => FALSE,
  );
  $this
    ->drupalPost('admin/content/node-type/' . $this->info->type, $edit, 'Save content type');
  $this
    ->assertRaw(t('Using FeedAPI for this content-type requires at least one enabled parser.'), 'The lack of parsers was detected.');
  $edit = array(
    'feedapi[processors][feedapi_node][enabled]' => FALSE,
  );
  $this
    ->drupalPost('admin/content/node-type/' . $this->info->type, $edit, 'Save content type');
  $this
    ->assertRaw(t('Using FeedAPI for this content-type requires at least one enabled processor.'), 'The lack of processors was detected.');
  $num = db_result(db_query("SELECT COUNT(*) FROM {feedapi}"));
  $this
    ->assertEqual($num, 0, 'No feed was created during the test.');
}