function ImportOPMLTestCase::validateImportFormFields

7.x aggregator.test ImportOPMLTestCase::validateImportFormFields()

Submits form filled with invalid fields.

1 call to ImportOPMLTestCase::validateImportFormFields()
ImportOPMLTestCase::testOPMLImport in drupal-7.x/modules/aggregator/aggregator.test
Tests the import of an OPML file.

File

drupal-7.x/modules/aggregator/aggregator.test, line 726
Tests for aggregator.module.

Class

ImportOPMLTestCase
Tests importing feeds from OPML functionality for the Aggregator module.

Code

function validateImportFormFields() {
  $before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();

  $edit = array();
  $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import'));
  $this->assertRaw(t('You must <em>either</em> upload a file or enter a URL.'), 'Error if no fields are filled.');

  $path = $this->getEmptyOpml();
  $edit = array(
    'files[upload]' => $path,
    'remote' => file_create_url($path),
  );
  $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import'));
  $this->assertRaw(t('You must <em>either</em> upload a file or enter a URL.'), 'Error if both fields are filled.');

  $edit = array('remote' => 'invalidUrl://empty');
  $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import'));
  $this->assertText(t('This URL is not valid.'), 'Error if the URL is invalid.');

  $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
  $this->assertEqual($before, $after, 'No feeds were added during the three last form submissions.');
}