I used a line similar to this one to edit a node:

$this->drupalPost("node/{$nid}/edit", array('body' => 'Hi!', 'status' => 0, 'promote' => 0), 'Save');

I discovered that the body had been changed (and the $node->changed timestamp changed as well), but the 'status' and 'promote' values were still both 1 as they were before. There were no other errors other than those unexpected values (e.g.: SimpleTest didn't tell me it couldn't find the status and promote fields when I attempted to submit the form via drupalPost).

Comments

boombatower’s picture

Status: Active » Postponed (maintainer needs more info)

Per documentation, checkboxes should be set with TRUE or FALSE. Although since PHP is not type strick I am not sure this is the issue.

   * @param  $edit
   *   Field data in an associative array. Changes the current input fields
   *   (where possible) to the values indicated. A checkbox can be set to
   *   TRUE to be checked and FALSE to be unchecked. Note that when a form
   *   contains file upload fields, other fields cannot start with the '@'
   *   character.
Mike Wacker’s picture

Status: Postponed (maintainer needs more info) » Active

Just replaced 0 with FALSE and I got the same results. Also, when I replicate this on Drupal 7, I get three extra errors that I don't see in Drupal 6:

"Failed to set field status to" (must have trouble writing out FALSE)
"Failed to set field promote to"
"Found the requested form fields at node/1/edit"

Should I also file this against core as well?

dave reid’s picture

I bet I know the problem. Make sure your testing user has the 'administer nodes' permission. Otherwise, those fields are not editable/visible to your testing user.

boombatower’s picture

Status: Active » Postponed (maintainer needs more info)

A good debug tool that can be placed after the drupalPost() to see what SimpleTest was looking at it:

file_put_contents('output.html', $this->drupalGetContent());
Mike Wacker’s picture

I'll look into it more, but the user definitely has 'administer nodes' permission. Plus, if that were the issue, then the node's body would not have been updated.

Mike Wacker’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

So playing around some more, I discovered that changing 0 to FALSE does actually work. I wonder if the issue of 0 and FALSE being different is easy to fix, though; maybe a simple boolean cast will do the trick.

I had some issues syncing files, which is what made things go wrong earlier when I changed 0 to FALSE. However, I haven't figured it out yet for Drupal 7, where I don't have any file syncing issues. I'll investigate that some more and file a core bug if I discover something.