You are here

public function FeedsRulesTest::testFeedsImportAction in Feeds 7.2

Tests the Rules action 'feeds_import_feed'.

File

tests/feeds_rules.test, line 197
Contains FeedsRulesTest.

Class

FeedsRulesTest
Tests for Rules integration.

Code

public function testFeedsImportAction() {

  // Attach importer to content type and set to not import on submission.
  $this
    ->setSettings('node', NULL, array(
    'content_type' => 'page',
    'import_period' => FEEDS_SCHEDULE_NEVER,
    'import_on_create' => FALSE,
  ));

  // Create a feed node.
  $source_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv';
  $this
    ->createFeedNode('node', $source_url, 'Feed node 1', 'page');

  // Assert that nothing has been imported yet.
  $this
    ->assertNodeCount(1);

  // Create rule with import action.
  $rule = $this
    ->createTestRule('cron', FALSE);
  $rule
    ->action('feeds_import_feed', array(
    'importer' => 'node',
    'feed_nid' => 1,
  ));
  $rule
    ->integrityCheck()
    ->save();

  // Trigger rules event.
  $this
    ->cronRun();

  // Assert that 2 items have been imported (three nodes exist in total).
  $this
    ->assertNodeCount(3);
}