public function FeedsRulesTest::testFeedsBeforeSavingItemEvent in Feeds 7.2
Tests if the Rules event 'feeds_import_IMPORTER_ID' is invoked.
File
- tests/
feeds_rules.test, line 138 - Contains FeedsRulesTest.
Class
- FeedsRulesTest
- Tests for Rules integration.
Code
public function testFeedsBeforeSavingItemEvent() {
$rule = $this
->createTestRule('feeds_import_node');
// Act before saving the second node.
$rule
->condition('data_is', array(
'data:select' => 'node:title',
'value' => 'Ut wisi enim ad minim veniam',
));
$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 importing the second item.
$node = node_load(2);
$this
->assertEqual('Test node', $node->title);
// Assert titles of imported nodes as well.
$node = node_load(1);
$this
->assertEqual('Lorem ipsum', $node->title);
$node = node_load(3);
$this
->assertEqual('Ut wisi enim ad minim veniam', $node->title);
}