public function FeedsCSVtoUsersTest::testUser1ProtectionWhenDeletingNonExistent in Feeds 7.2
Tests if user 1 cannot be deleted using the delete non-existing feature.
File
- tests/
feeds_processor_user.test, line 926 - Tests for plugins/FeedsUserProcessor.inc.
Class
- FeedsCSVtoUsersTest
- Test aggregating a feed as data records.
Code
public function testUser1ProtectionWhenDeletingNonExistent() {
// Set to delete non-existing users.
$this
->setSettings('user_import', 'FeedsFileFetcher', array());
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
'update_non_existent' => 'delete',
));
// Set mail address of user 1 to "fester@example.com". An user with this
// mail address is missing in the feed later.
$account = user_load(1);
$edit['mail'] = 'fester@example.com';
user_save($account, $edit);
// Import the first file, which contains the mail address of user 1.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
$this
->assertText('Updated 1 user');
// Ensure the username of user 1 was updated.
$account = user_load(1, TRUE);
$this
->assertEqual('Fester', $account->name);
// Now import the second file, where the mail address of user 1 is missing.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users2.csv');
$this
->assertNoText('Removed 1 user');
// Ensure that user 1 still exists.
$account = db_select('users')
->fields('users')
->condition('uid', 1)
->execute()
->fetch();
$this
->assertTrue(is_object($account), 'User 1 still exists.');
}