public function testCollectionAndisCollection() { $model = new ModelBase(); $this->assertFalse($model->isCollection(null)); $someCollection = $model->collection(array(1, 2, 3)); $this->assertTrue($model->isCollection($someCollection)); }
/** * Saving data must store it in the database */ public function testModelSave() { $data = array('_id' => 1, 'testingData' => uniqid()); Base::$collection = 'model_test'; $this->assertEquals(0, $this->mongo->selectCollection(Base::$collection)->count()); $model = new Base($data); $this->assertEquals(0, $this->mongo->selectCollection(Base::$collection)->count()); $model->save(); $this->assertEquals(1, $this->mongo->selectCollection(Base::$collection)->count()); $this->assertEquals($model->asArray(), $this->mongo->selectCollection(Base::$collection)->findOne()); }