addMaster() public static method

Add a connection to a master server
public static addMaster ( Shanty_Mongo_Connection $connection, integer $weight = 1, $connectionGroup = 'default' )
$connection Shanty_Mongo_Connection
$weight integer
Exemplo n.º 1
0
 public function testGetDbName()
 {
     $this->assertEquals(TESTS_SHANTY_MONGO_DB, My_ShantyMongo_User::getDbName());
     Shanty_Mongo::removeConnectionGroups();
     $connection = new Shanty_Mongo_Connection('localhost/shanty-mongo');
     Shanty_Mongo::addMaster($connection);
     $this->assertEquals(TESTS_SHANTY_MONGO_DB, My_ShantyMongo_User::getDbName());
     $this->assertEquals('shanty-mongo', My_ShantyMongo_Name::getDbName());
 }
Exemplo n.º 2
0
 /**
  * @depends testAddMaster
  */
 public function testGetWriteConnection()
 {
     $connection = Shanty_Mongo::getWriteConnection();
     $this->assertNotNull($connection);
     $connectionInfo = $connection->getConnectionInfo();
     $this->assertEquals('127.0.0.1', $connectionInfo['connectionString']);
     Shanty_Mongo::removeConnectionGroups();
     $connection = $this->getMock('Shanty_Mongo_Connection');
     Shanty_Mongo::addMaster($connection);
     $this->assertEquals($connection, Shanty_Mongo::getWriteConnection());
     Shanty_Mongo::removeConnectionGroups();
     $connection = $this->getMock('Shanty_Mongo_Connection');
     Shanty_Mongo::addMaster($connection, 1, 'users');
     $this->assertEquals($connection, Shanty_Mongo::getWriteConnection('users'));
 }
Exemplo n.º 3
0
 public function setUp()
 {
     $this->_useMyIncludePath();
     require_once 'My/ShantyMongo/User.php';
     require_once 'My/ShantyMongo/Users.php';
     require_once 'My/ShantyMongo/Name.php';
     require_once 'My/ShantyMongo/Student.php';
     require_once 'My/ShantyMongo/ArtStudent.php';
     require_once 'My/ShantyMongo/Teacher.php';
     require_once 'My/ShantyMongo/Article.php';
     require_once 'My/ShantyMongo/InvalidDocument.php';
     $this->_connection = new Shanty_Mongo_Connection(TESTS_SHANTY_MONGO_CONNECTIONSTRING);
     $this->_connection->connect();
     Shanty_Mongo::addMaster($this->_connection);
     $this->_connection->selectDb(TESTS_SHANTY_MONGO_DB)->selectCollection('user')->drop();
     $this->_connection->selectDb(TESTS_SHANTY_MONGO_DB)->selectCollection('article')->drop();
     $this->populateDb();
 }