Example #1
0
 function testCount()
 {
     $m1 = new Model1();
     $m2 = new Model2();
     $this->assertEquals($m1->count(), count($m1));
     $this->assertEquals($m2->count(), count($m2));
 }
Example #2
0
 function __construct($id = 0)
 {
     parent::__construct();
     $this->properties['posts'] = array('id', 'hash_code', 'content_type', 'hash_code_author', 'date_created', 'date_editing', 'title', 'title_for_url', 'text_post', 'tags', 'attached_file', 'views');
     if ($id) {
         $this->getData($id);
     }
 }
Example #3
0
 /**
  *  Testing hook, modifing on update other documents
  */
 function testChanges()
 {
     Model1::addEvent('after_update', array($this, 'model1_after_update'));
     $m1 = new Model1();
     $m1->a = 1;
     $m1->b = 2;
     $m1->save();
     $data = array();
     for ($i = 0; $i < 1000; $i++) {
         $m2['M1'] = $m1->getID();
         $m2['a'] = $m1->a;
         $data[] = $m2;
     }
     Model2::batchInsert($data);
     $m1->a = 50;
     $m1->save();
     $m2 = new Model2();
     foreach ($m2->where("M1", $m1->getID()) as $item) {
         $this->assertEquals($m1->a, $item->a);
     }
 }
Example #4
0
 function testInvalidBatchInsert()
 {
     /* Invalid document for Model2 */
     $documents = array(array('foo' => 'bar'));
     try {
         /* Invalid call */
         ActiveMongo::BatchInsert($documents);
         $this->assertTrue(False);
     } catch (ActiveMongo_Exception $e) {
         $this->assertTrue(TRUE);
     }
     try {
         Model2::BatchInsert($documents);
         $this->assertTrue(False);
     } catch (ActiveMongo_FilterException $e) {
         $this->assertTrue(FALSE);
     } catch (MongoException $e) {
         $this->assertTrue(TRUE);
     }
     try {
         Model2::BatchInsert($documents, TRUE, FALSE);
         $this->assertTrue(False);
     } catch (ActiveMongo_FilterException $e) {
         $this->assertTrue(TRUE);
     }
 }
Example #5
0
 public function testInvalidRefernce()
 {
     $c = new Model2();
     $this->assertTrue($c->getReference() === NULL);
 }
Example #6
0
 public function testClassToTableWithTable()
 {
     $this->assertEquals('model_1', Model2::test_class_to_table('model_1'));
 }