function testCustomLazyFieldsInFindFirst()
 {
     $object = new TestOneTableObject();
     $object->setAnnotation($annotation = "Annotation");
     $object->setContent($content = "Content");
     $object->save();
     $object2 = lmbActiveRecord::findFirst('TestOneTableObject', array('fields' => array('annotation')));
     $fields = $object2->exportRaw();
     //checking which props were actually loaded
     $this->assertEqual($fields, array('id' => $object->getId(), 'annotation' => $annotation));
     //lazy loading in action
     $this->assertEqual($object2->getAnnotation(), $annotation);
     $this->assertEqual($object2->getContent(), $content);
 }
 function initOneTableObject($ordr = '')
 {
     $object = new TestOneTableObject();
     $object->set('annotation', 'Annotation ' . rand(0, 1000));
     $object->set('content', 'Content ' . rand(0, 1000));
     $object->set('news_date', date("Y-m-d", time()));
     $ordr = $ordr ?: rand(0, 1000);
     $object->set('ordr', $ordr);
     return $object;
 }
 function testSettingSameTablePropertyValueDoesntMakeObjectDirty()
 {
     $object = new TestOneTableObject();
     $object->setContent('whatever');
     $object->save();
     $this->assertFalse($object->isDirty());
     $object->setContent($object->getContent());
     $this->assertFalse($object->isDirty());
     $object->setContent('whatever else');
     $this->assertTrue($object->isDirty());
 }
 function testGetTableName()
 {
     $object = new TestOneTableObject();
     $this->assertEqual($object->getTableName(), 'test_one_table_object');
 }
 function testDestroyRecordForGlobalListener()
 {
     $object = new TestOneTableObject();
     $object->set('annotation', 'Super annotation');
     $object->set('content', 'Super content');
     $object->set('news_date', '2005-01-10');
     $object->save();
     $delegate = new lmbActiveRecordEventHaldlerStubDelegate();
     $delegate->subscribeGloballyForEvents($object);
     $object->destroy();
     $this->assertEqual($delegate->getCallsOrder(), '|onBeforeDestroy TestOneTableObject||onAfterDestroy TestOneTableObject|');
 }
 function testPassingArrayToConstructorCallsImport()
 {
     $source = array('id' => 1000, 'annotation' => 'Some annotation', 'content' => 'Some content');
     $object = new TestOneTableObject($source);
     $this->assertEqual($object->getId(), 1000);
     $this->assertEqual($object->getAnnotation(), 'Some annotation');
     $this->assertEqual($object->getContent(), 'Some content');
 }