API page: https://api.drupal.org/api/drupal/core%21modules%21simpletest%21lib%21Dr...
Enter a descriptive title (above) relating to protected function WebTestBase::drupalCreateNode, then describe the problem you have found:
The documentation and code for WebTestBase::drupalCreateNode() says that you can set $settings['changed'] to a value and it will be set on the node.
This is not correct. See Node::preSave() -- it always sets the value of changed to the request time, which in a test is always when you started the test (constant for all nodes created during the test, and nothing you can do about it as far as I can tell).
We should just take the 'changed' attribute out of the documentation and code of WebTestBase, unless we are allowed to fix Node::preSave() so that it only sets 'changed' if it wasn't already set to a value.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2213411-simple-fix-4.patch | 933 bytes | jhodgdon |
Comments
Comment #1
tim.plunkettYep, see #722688: Allow programmatic setting of node->changed and #322759: Allow hook_node_presave() to alter other node fields for historical issues about this.
We needed to test the sorting of this for /admin/content, and to work around that we had to do this:
Comment #2
jhodgdonHere is a simple patch that just removes 'changed' from the docs and code, since it (at least currently) has no effect.
Comment #4
jhodgdonI guess that patch was made on an old repo. Here's a new one.
Comment #5
BerdirYep, makes sense.
Comment #6
webchickOk, then.
Committed and pushed to 8.x. Thanks!