function ImportOpmlTest::validateImportFormFields

Submits form filled with invalid fields.

1 call to ImportOpmlTest::validateImportFormFields()
ImportOpmlTest::testOpmlImport in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/ImportOpmlTest.php
Tests the import of an OPML file.

File

drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/ImportOpmlTest.php, line 65
Definition of Drupal\aggregator\Tests\ImportOpmlTest.

Class

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

Namespace

Drupal\aggregator\Tests

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('The URL invalidUrl://empty 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.');
}