コード例 #1
0
ファイル: ArrayTest.php プロジェクト: 284099857/ActiveMongo
 function testScalarToArray()
 {
     $c = new Model1();
     $c->a = 1;
     $c->save();
     $c->a = array(1, 2);
     $c->save();
     $c->a[0] = array(1, 2);
     $c->a[1] = 3;
     $c->save();
     $id = $c->getID();
     $c->reset();
     $c->where('_id', $id);
     $c->doQuery();
     $this->assertEquals(array(array(1, 2), 3), $c->a);
 }
コード例 #2
0
ファイル: QueryTest.php プロジェクト: 284099857/ActiveMongo
 /**
  * @depends testBulkInserts
  */
 function testClone()
 {
     $c = new Model1();
     $c->a = 1;
     $c->save();
     $c->reset();
     /* object with no results can't be cloned */
     try {
         $foo = clone $c;
         $this->AssertTrue(FALSE);
     } catch (ActiveMongo_Exception $e) {
         $this->AssertTrue(TRUE);
     }
     foreach ($c as $item) {
         $item_cloned = clone $item;
         $item_cloned->c = 1;
         $item_cloned->save();
         try {
             /* iterations are forbidden in cloned objects */
             foreach ($item_cloned as $nitem) {
                 $this->assertTrue(FALSE);
             }
         } catch (ActiveMongo_Exception $e) {
             $this->assertTrue(TRUE);
         }
     }
     /* cloned object can't be reused */
     try {
         $item_cloned->reset();
         $this->AssertTrue(FALSE);
     } catch (ActiveMongo_Exception $e) {
         $this->AssertTrue(TRUE);
     }
     try {
         $item_cloned->where('a IN', array(1));
         $this->AssertTrue(FALSE);
     } catch (ActiveMongo_Exception $e) {
         $this->AssertTrue(TRUE);
     }
 }