I was writing a test for the blog module using SimpleTest when I found the following issue.
$this->own_user = $this->drupalCreateUser(array('create blog content', 'edit own blog content', 'delete own blog content'));
$this->drupalLogin($this->own_user);
// Create test node.
$node1 = $this->drupalCreateNode(array('type' => 'blog'));
$this->drupalGet('node/'. $node1->nid);
var_dump($this->drupalGetContent());
// Edit test node.
$edit = array();
$edit['title'] = 'node/' . $node1->nid;
$edit['body'] = $this->randomName(8);
$this->drupalPost('node/'. $node1->nid .'/edit', $edit, t('Save'));
$this->assertWantedRaw(t('Blog entry %title has been updated.', array('%title' => $edit['title'])), t('Node edited successfully.'));
After creating the blog node and dumping the node page, it appears the blog node was successfully created. When attempting to edit the blog node, the test failed.
When I changed the privilege to 'edit any blog content' the test passed.
Comments
Comment #1
boombatower commentedDiscovered that this is due to an issue in
drupalCreateNode.This is related to http://drupal.org/node/212304.
Comment #2
beeradb commented@Boombatower: By Discovering this is due to the drupalCreateNode issue I assume you mean because when using drupalCreateNode the node is saved as the user _running_ the tests rather than the test user which is logged in?
Comment #3
boombatower commented@beeradb: Correct. I relize this can be overcome by passing
$settings['uid']todrupalCreateNode, but doesn't make sense that it wouldn't create it as the logged in user.@all: This could be fixed in two different ways.
DrupalTestCaseand then simple access it to get the user id.DrupalTestCaseto use internal browser (ie.drupalPost) instead.This is already be discussed and needs to be decided upon. This issue leads me more towards thinking it should use the second option, although we could provide either, but that could get messy.
Comment #4
boombatower commentedOnce http://drupal.org/node/212304 has been delt with this code will need to be changed.
Comment #5
boombatower commentedActually this is a test issue.
Comment #6
boombatower commentedComment #7
boombatower commentedAssume this is fixed, but should be evaluated against 8.x. #4 is no longer a concern.
Comment #8
boombatower commentedComment #9
jhedstrom#233301: Remove blog module from core.