コード例 #1
0
 public function testFind()
 {
     $this->object->storeFile('tests/somefile');
     $cursor = $this->object->find();
     $this->assertTrue($cursor instanceof MongoGridFSCursor);
     $file = $cursor->getNext();
     $this->assertNotNull($file);
     $this->assertTrue($file instanceof MongoGridFSFile);
 }
コード例 #2
0
ファイル: SlowTests.php プロジェクト: kph11/mongo-php-driver
 /**
  * @expectedException MongoCursorTimeoutException
  */
 public function testStaticTimeout()
 {
     $this->markTestSkipped("for now");
     return;
     MongoCursor::$timeout = 1;
     for ($i = 0; $i < 1000; $i++) {
         $this->object->insert(array("x" => "sdfjnaireojaerkgmdfkngkdsflngklsgntoigneorisgmsrklgd{$i}", "y" => $i));
     }
     $rows = $this->object->find(array('$eval' => 'r = 0; cursor = db.c.find(); while (cursor.hasNext()) { x = cursor.next(); for (i=0; i<200; i++) { if (x.name == "joe"+i) { r++; } } } return r;'));
     foreach ($rows as $row) {
     }
     MongoCursor::$timeout = 30000;
 }
コード例 #3
0
 public function testTimeout2()
 {
     $cmd = $this->object->db->selectCollection('$cmd');
     for ($i = 0; $i < 10000; $i++) {
         $this->object->insert(array("name" => "joe" . $i, "interests" => array(rand(), rand(), rand())));
     }
     // shouldn't time out
     $r = $this->object->find()->timeout(5000)->getNext();
     // not testing functionality, just making sure it's testing the right data
     $this->assertEquals("joe", substr($r['name'], 0, 3));
     // shouldn't time out, does take a while
     $query = 'r = 0; cursor = db.c.find(); while (cursor.hasNext()) { x = cursor.next(); for (i=0; i<200; i++) { if (x.name == "joe"+i) { r++; } } } return r;';
     $r = $cmd->find(array('$eval' => $query))->limit(-1)->getNext();
 }
コード例 #4
0
 public function testPartial() {
     $cursor = $this->object->find();
     $cursor->partial()->partial(true)->partial(false);
     $cursor->hasNext();
     $cursor->reset();
     $cursor->partial(true);
     $cursor->hasNext();
 }
コード例 #5
0
 public function testExplainReset()
 {
     $this->object->insert(array("x" => "abc"), array('safe' => true));
     $cursor = $this->object->find();
     $qp = $cursor->explain();
     $info = $cursor->info();
     $this->assertTrue(!array_key_exists('$explain', $info['query']));
     $this->assertTrue(array_key_exists('$query', $info['query']));
     $doc = $cursor->getNext();
     $this->assertEquals('abc', $doc['x'], json_encode($doc));
 }
コード例 #6
0
 public function testExplainLimit()
 {
     $this->object->drop();
     for ($i = 0; $i < 100; $i++) {
         $this->object->save(array("x" => $i));
     }
     $q = array("x" => array('$gt' => 50));
     $soft = $this->object->find($q)->limit(20)->explain();
     $hard = $this->object->find($q)->limit(-20)->explain();
     $this->assertEquals(20, $soft['n']);
     $this->assertEquals(20, $hard['n']);
 }