You are here

public function ImportOpmlTest::validateImportFormFields in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/aggregator/src/Tests/ImportOpmlTest.php \Drupal\aggregator\Tests\ImportOpmlTest::validateImportFormFields()

Submits form filled with invalid fields.

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

File

core/modules/aggregator/src/Tests/ImportOpmlTest.php, line 51
Contains \Drupal\aggregator\Tests\ImportOpmlTest.

Class

ImportOpmlTest
Tests OPML import.

Namespace

Drupal\aggregator\Tests

Code

public function validateImportFormFields() {
  $before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')
    ->fetchField();
  $edit = array();
  $this
    ->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
  $this
    ->assertRaw(t('<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
    ->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
  $this
    ->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if both fields are filled.');
  $edit = array(
    'remote' => 'invalidUrl://empty',
  );
  $this
    ->drupalPostForm('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.');
}