public function FeedsRulesTest::testFeedsBeforeImportEvent in Feeds 7.2
Tests if the Rules event 'feeds_before_import' is invoked.
File
- tests/
feeds_rules.test, line 78 - Contains FeedsRulesTest.
Class
- FeedsRulesTest
- Tests for Rules integration.
Code
public function testFeedsBeforeImportEvent() {
$rule = $this
->createTestRule('feeds_before_import');
$rule
->condition('data_is', array(
'data:select' => 'source:id',
'value' => 'node',
));
$rule
->integrityCheck()
->save();
// Set source file to import.
$source_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv';
$edit = array(
'feeds[FeedsHTTPFetcher][source]' => $source_url,
);
$this
->drupalPost('import/node', $edit, t('Import'));
$this
->assertText('Created 2 nodes');
// Assert that a test node was created *before* the import.
$node = node_load(1);
$this
->assertEqual('Test node', $node->title);
// Assert titles of imported nodes as well.
$node = node_load(2);
$this
->assertEqual('Lorem ipsum', $node->title);
$node = node_load(3);
$this
->assertEqual('Ut wisi enim ad minim veniam', $node->title);
}