public function FeedsRSStoNodesTest::testAuthorize in Feeds 8.2
Test that nodes will not be created if the user is unauthorized to create them.
File
- lib/
Drupal/ feeds/ Tests/ FeedsRSStoNodesTest.php, line 410 - Tests for plugins/FeedsNodeProcessor.inc.
Class
- FeedsRSStoNodesTest
- Test aggregating a feed as node items.
Namespace
Drupal\feeds\TestsCode
public function testAuthorize() {
// Create a user with limited permissions.
$account = $this
->drupalCreateUser(array(), 'Development Seed');
// Adding a mapping to the user_name will invoke authorization.
$this
->addMappings('syndication', array(
5 => array(
'source' => 'author_name',
'target' => 'user_name',
),
));
$nid = $this
->createFeedNode();
$this
->assertText('Failed importing 10 nodes.');
$this
->assertText('User ' . $account->name . ' is not authorized to create content type article.');
$node_count = db_query("SELECT COUNT(*) FROM {node}")
->fetchField();
// We should have 1 node, the feed node.
$this
->assertEqual($node_count, 1, t('Correct number of nodes in the database.'));
// Give the user super admin powers.
user_delete($account->uid);
$account = $this
->drupalCreateUser(array(
'access content',
'bypass node access',
), 'Development Seed');
$this
->drupalPost("node/{$nid}/import", array(), 'Import');
$this
->assertText('Created 10 nodes.');
$node_count = db_query("SELECT COUNT(*) FROM {node}")
->fetchField();
$this
->assertEqual($node_count, 11, t('Correct number of nodes in the database.'));
}