Example #1
0
 public function testWhereNoneOf()
 {
     $documentId = $this->collection->createDocument(array('p' => array(1, 2, 3, 4, 5)))->save();
     $documents = $this->collection->find()->whereNoneOf('p', array(1, 4))->findAll();
     $this->assertEquals(0, count($documents));
 }
Example #2
0
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Update error: some_strange_error: Some strange error
  */
 public function testSave_UpdateError()
 {
     $mongoCollectionMock = $this->getMock('\\MongoCollection', array('update'), array($this->collection->getDatabase()->getMongoDb(), 'phpmongo_test_collection'));
     $mongoCollectionMock->expects($this->once())->method('update')->will($this->returnValue(array('ok' => (double) 0, 'err' => 'some_strange_error', 'errmsg' => 'Some strange error')));
     $collection = new Collection($this->collection->getDatabase(), $mongoCollectionMock);
     // create document
     $document = $collection->createDocument(array('p' => 'v'))->save();
     // update document with error
     $document->set('p', 'v1')->save();
 }