Example #1
0
 public function testSetSlaveOkayPreservesReadPreferenceTags()
 {
     $mongoDB = $this->getMockMongoDB();
     $mongoDB->expects($this->exactly(2))->method('getReadPreference')->will($this->returnValue(['type' => \MongoClient::RP_PRIMARY_PREFERRED, 'tagsets' => [['dc' => 'east']]]));
     $mongoDB->expects($this->once())->method('setReadPreference')->with(\MongoClient::RP_SECONDARY_PREFERRED, [['dc' => 'east']])->will($this->returnValue(false));
     $database = new Database($this->getMockConnection(), $mongoDB, $this->getMockEventManager());
     $this->assertEquals(true, $database->setSlaveOkay(true));
 }
Example #2
0
 public function testSetSlaveOkayPreservesReadPreferenceTags()
 {
     if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
         $this->markTestSkipped('This test is not applicable to driver versions < 1.3.0');
     }
     $this->mongodb->expects($this->exactly(2))->method('getReadPreference')->will($this->returnValue(array('type' => 1, 'type_string' => 'primary preferred', 'tagsets' => array(array('dc:east')))));
     $this->mongodb->expects($this->once())->method('setReadPreference')->with(\MongoClient::RP_SECONDARY_PREFERRED, array(array('dc' => 'east')))->will($this->returnValue(false));
     $database = new Database($this->connection, 'test', $this->getMockEventManager(), '$');
     $this->assertEquals(true, $database->setSlaveOkay(true));
 }