Test entity count query.
protected function testCount() {
// Attach the existing 'figures' field to a second entity type so that we
// can test whether cross entity type fields produce the correct query.
$field_name = $this->figures;
$bundle = $this
->randomName();
$instance = array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => $bundle,
);
field_create_instance($instance);
$entity = entity_create('entity_test', array(
'id' => 1,
'type' => $bundle,
));
$entity
->enforceIsNew();
$entity
->setNewRevision();
$entity
->save();
// As the single entity of this type we just saved does not have a value
// in the color field, the result should be 0.
$count = $this->factory
->get('entity_test')
->exists("{$field_name}.color")
->count()
->execute();
$this
->assertFalse($count);
}