EFQ propertyCondition Doesn't work in Simpletest This Entity Field Query works as expected outside of simpletest:

$query-&gt;entityCondition('entity_type', 'node')
  -&gt;fieldCondition('field_exhibition_window_start', 'value', $date, '&lt;=')
  -&gt;fieldCondition('field_exhibition_window_end', 'value', $date, '&gt;=')
  -&gt;addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT')
  -&gt;propertyCondition('status', '0');


Inside of a simpletest, after the creation of an unpublished node within specified parameters, it unexpectedly returns zero results.

However, if I comment out this line:

  -&gt;propertyCondition('status', '0');


(and put a semicolon on the line above) then the query works as expected and returns a node ID. I've even done a node_load() on the node ID returned and inspected the node to be sure that it is, in fact, at that exact moment in time, unpublished.

My simpletest has a user with node access bypass permissions, and I'm using DANGEROUS_ACCESS_CHECK_OPT_OUT, so it doesn't seem like a permissions issue.

Does Simpletest do something weird with EFQs? Why isn't it finding my unpublished node?
It turns out that the status of my node was, in fact, being set to '1' immediately prior to this query running, but that despite the fact that the node_save() that was called immediately after node_publish_action() should have cleared the cache, node_load() was in fact calling a cached version of the node.

I got around this by adding the TRUE parameter to node_load().

NOTE: You can't skip the middle parameter, á la node_load($nid, TRUE). This is annoying, because it will fail silently and it will just return a boolean FALSE. To get a node without caching, and also without specifying a VID, you must use node_load($nid, NULL, TRUE).

In a simpletest, you can also use a TRUE parameter like so:  drupalWebTestCase::drupalGetNodeByTitle($nid, TRUE).