feeds_fetcher_http.test 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @file
  4. * Contains FeedsFileHTTPTestCase.
  5. */
  6. /**
  7. * HTTP fetcher test class.
  8. */
  9. class FeedsFileHTTPTestCase extends FeedsWebTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Fetcher: HTTP',
  13. 'description' => 'Tests for file http fetcher plugin.',
  14. 'group' => 'Feeds',
  15. );
  16. }
  17. /**
  18. * Test the Feed URL form.
  19. */
  20. public function testFormValidation() {
  21. // Set up an importer.
  22. $id = drupal_strtolower($this->randomName());
  23. $this->createImporterConfiguration($this->randomString(), $id);
  24. // Check that by default, we add http:// to the front of the URL.
  25. $edit = array(
  26. 'feeds[FeedsHTTPFetcher][source]' => 'example.com',
  27. );
  28. $this->drupalPost('import/' . $id, $edit, t('Import'));
  29. $this->assertText(t('There are no new nodes.'));
  30. $this->assertFieldByName('feeds[FeedsHTTPFetcher][source]', 'http://example.com');
  31. $this->setSettings($id, 'FeedsHTTPFetcher', array('auto_scheme' => 'feed'));
  32. $this->drupalPost('import/' . $id, $edit, t('Import'));
  33. $this->assertText(t('There are no new nodes.'));
  34. $this->assertFieldByName('feeds[FeedsHTTPFetcher][source]', 'feed://example.com');
  35. $this->setSettings($id, 'FeedsHTTPFetcher', array('auto_scheme' => ''));
  36. $this->drupalPost('import/' . $id, $edit, t('Import'));
  37. $this->assertText(t('The URL example.com is invalid.'));
  38. $this->assertFieldByName('feeds[FeedsHTTPFetcher][source]', 'example.com');
  39. }
  40. }