function testUpdateWhileNoDirtyFields() { $object = new TestOneTableObject(); $object->setAnnotation($initial_annotation = 'some annotation'); $object->setContent($initial_content = 'some content'); $object->save(); $object->setAnnotation('some other annotation'); $object->setContent('some other content'); $object->resetPropertyDirtiness('content'); $object->resetPropertyDirtiness('annotation'); $object->save(); $loaded_object = lmbActiveRecord::findById('TestOneTableObject', $object->getId()); $this->assertEqual($loaded_object->getAnnotation(), $initial_annotation); $this->assertEqual($loaded_object->getContent(), $initial_content); }
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 testImportPreservesIdOfExistingObject() { $object = new TestOneTableObject(); $object->setAnnotation('Initial annotation'); $object->save(); $id = $object->getId(); $source = array('id' => 10000, 'annotation' => 'Some annotation', 'content' => 'Some content'); $object->import($source); $this->assertEqual($object->getId(), $id); $this->assertNotEqual($object->getId(), 1000); // just one extra check $this->assertEqual($object->getAnnotation(), 'Some annotation'); $this->assertEqual($object->getContent(), 'Some content'); }