initialize() public method

This method will dispatch preConnect and postConnect events.
public initialize ( )
Beispiel #1
0
 public function testInitialize()
 {
     $conn = new Connection();
     $this->assertNull($conn->getMongo());
     $conn->initialize();
     $this->assertInstanceOf('Mongo', $conn->getMongo());
 }
Beispiel #2
0
 public function testEventArgsNamespaceTest()
 {
     $listener = new ListenerStub();
     $manager = new EventManager();
     $manager->addEventListener(\Doctrine\MongoDB\Events::preConnect, $listener);
     $connection = new Connection(null, [], null, $manager);
     $connection->initialize();
 }
Beispiel #3
0
 public function testInitializeMongoClient()
 {
     if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
         $this->markTestSkipped('This test is not applicable to driver versions < 1.3.0');
     }
     $conn = new Connection();
     $this->assertNull($conn->getMongo());
     $conn->initialize();
     $this->assertInstanceOf('MongoClient', $conn->getMongo());
 }
Beispiel #4
0
 public function testConnectTimeoutOptionIsConverted()
 {
     if (version_compare(phpversion('mongo'), '1.4.0', '<')) {
         $this->markTestSkipped('This test is not applicable to driver versions < 1.4.0');
     }
     /* Since initialize() creates MongoClient directly, we cannot examine
      * the options passed to its constructor.
      *
      * Note: we do not test "wTimeout" conversion, since the driver does not
      * raise a deprecation notice for its usage (see: PHP-1079).
      */
     $conn = new Connection(null, array('timeout' => 10000));
     $conn->initialize();
 }
Beispiel #5
0
 public function testConnectTimeoutOptionIsConverted()
 {
     /* Since initialize() creates MongoClient directly, we cannot examine
      * the options passed to its constructor.
      *
      * Note: we do not test "wTimeout" conversion, since the driver does not
      * raise a deprecation notice for its usage (see: PHP-1079).
      */
     $conn = new Connection(null, ['timeout' => 10000]);
     $conn->initialize();
 }