function testCount() { $m1 = new Model1(); $m2 = new Model2(); $this->assertEquals($m1->count(), count($m1)); $this->assertEquals($m2->count(), count($m2)); }
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); } }
/** * 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); } }
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); } }
public function testInvalidRefernce() { $c = new Model2(); $this->assertTrue($c->getReference() === NULL); }
public function testClassToTableWithTable() { $this->assertEquals('model_1', Model2::test_class_to_table('model_1')); }