public function testWithReadPreference()
{
$collection = $this->getMockCollection();
$collection->expects($this->at(0))->method('getReadPreference')->will($this->returnValue(['type' => 'primary']));
$collection->expects($this->at(1))->method('setReadPreference')->with('secondary', [['dc' => 'east']]);
$collection->expects($this->at(2))->method('count')->with(['foo' => 'bar'])->will($this->returnValue(100));
$collection->expects($this->at(3))->method('setReadPreference')->with('primary');
$queryArray = ['type' => Query::TYPE_COUNT, 'query' => ['foo' => 'bar'], 'readPreference' => 'secondary', 'readPreferenceTags' => [['dc' => 'east']]];
$query = new Query($collection, $queryArray, []);
$this->assertEquals(100, $query->execute());
}