You are here

public function FeedsRulesTest::testFeedsImportActionWithProcessInBackgroundOption in Feeds 7.2

Tests the Rules action 'feeds_import_feed' with process in background.

File

tests/feeds_rules.test, line 260
Contains FeedsRulesTest.

Class

FeedsRulesTest
Tests for Rules integration.

Code

public function testFeedsImportActionWithProcessInBackgroundOption() {

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

  // 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('feeds_tests_rules_event', FALSE);
  $rule
    ->action('feeds_import_feed', array(
    'importer' => 'node',
    'feed_nid' => 1,
  ));
  $rule
    ->integrityCheck()
    ->save();

  // Trigger rules event.
  $this
    ->drupalGet('testing/feeds/trigger-rules-event');

  // Run cron to run background task.
  $this
    ->cronRun();

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