function ImportOPMLTestCase::validateImportFormFields

Submits form filled with invalid fields.

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

File

modules/aggregator/aggregator.test, line 766

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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.