Пример #1
0
 protected function classSetUp()
 {
     $config = ['database' => 'reach_testing', 'host' => 'localhost', 'port' => 27017, 'options' => ['connect' => true, 'socketTimeoutMS' => 60000]];
     ConnectionManager::registerConnection($config);
     /** @var Connection _connection */
     $this->_connection = ConnectionManager::getConnection();
     TestSchema::getCollection()->drop();
     TestSchema::getCollection()->addIndexes([['object.type', 'object.rnd', 'created']]);
     $this->_memory = memory_get_usage(true);
 }
Пример #2
0
 public function testStats()
 {
     //$stats = TestSchema::getCollection()->stats();
     //$this->assertTrue(is_array($stats));
     //$this->assertEquals(['ok' => 0, 'errmsg' => 'Collection [reach_testing.test_model_mongo_document] not found.'], $stats);
     $model = new TestSchema(['title' => 'CollectionStatsTitle']);
     $model->save();
     $stats = TestSchema::getCollection()->stats();
     $this->assertTrue(is_array($stats));
     $this->assertEquals(1, $stats['ok']);
 }
Пример #3
0
 public function testIdentityMapOverflow()
 {
     $model = new TestSchema(['title' => 'TitleFirst']);
     $model->save();
     $first_id = $model->_id;
     for ($i = 0; $i < 1000; $i++) {
         $model = new TestSchema(['title' => 'Title' . $i]);
         $model->save();
     }
     $this->assertFalse(TestSchema::getCollection()->getIdentityMap($first_id));
     TestSchema::deleteAll();
 }