Changeset 7443
- Timestamp:
- 02/09/08 22:12:13 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelVersionableBehaviorPlugin/trunk/README
r7406 r7443 304 304 == Changelog == 305 305 306 === 2008-02-0 8| Trunk ===306 === 2008-02-09 | Trunk === 307 307 308 308 * francois: Added `getCurrentResourceVersion`, `setResourceCreatedBy`, `getResourceCreatedBy`, `setResourceComment` and `getResourceComment` methods to the public API plugins/sfPropelVersionableBehaviorPlugin/trunk/lib/sfPropelVersionableBehavior.class.php
r7406 r7443 173 173 } 174 174 self::incrementVersion($resource); 175 if(!$createdBy && isset($resource->versionCreatedBy) && $resource->versionCreatedBy != '') 176 { 177 $createdBy = $resource->versionCreatedBy; 178 $resource->versionCreatedBy = ''; 179 } 180 if(!$comment && isset($resource->versionComment) && $resource->versionComment != '') 181 { 182 $comment = $resource->versionComment; 183 $resource->versionComment = ''; 184 } 175 185 self::createResourceVersion($resource, $createdBy, $comment); 176 186 } … … 222 232 public function getVersionComment(BaseObject $resource) 223 233 { 224 if(isset($resource->versionComment) )234 if(isset($resource->versionComment) && $resource->versionComment) 225 235 { 226 236 return $resource->versionComment; … … 253 263 public function getVersionCreatedBy(BaseObject $resource) 254 264 { 255 if(isset($resource->versionCreatedBy) )265 if(isset($resource->versionCreatedBy) && $resource->versionCreatedBy) 256 266 { 257 267 return $resource->versionCreatedBy; … … 300 310 if (self::versionConditionMet($resource)) 301 311 { 302 self::createResourceVersion($resource, isset($resource->versionCreatedBy) ? $resource->versionCreatedBy : '', isset($resource->versionComment) ? $resource->versionComment : ''); 312 $createdBy = ''; 313 $comment = ''; 314 if(isset($resource->versionCreatedBy) && $resource->versionCreatedBy != '') 315 { 316 $createdBy = $resource->versionCreatedBy; 317 $resource->versionCreatedBy = ''; 318 } 319 if(isset($resource->versionComment) && $resource->versionComment != '') 320 { 321 $comment = $resource->versionComment; 322 $resource->versionComment = ''; 323 } 324 self::createResourceVersion($resource, $createdBy, $comment); 303 325 } 304 326 if(isset($resource->resourceVersion) && $resource->resourceVersion instanceOf ResourceVersion) plugins/sfPropelVersionableBehaviorPlugin/trunk/test/unit/PropelVersionableBehaviorTest.php
r7406 r7443 78 78 )))); 79 79 80 $t = new lime_test(4 3, new lime_output_color());80 $t = new lime_test(49, new lime_output_color()); 81 81 82 82 // save() … … 125 125 $t->is($r2->getVersionCreatedBy(), 'foo', 'getVersionCreatedBy() returns the creation date of the revision'); 126 126 $t->is($r3->getVersionCreatedBy(), 'foo', 'getVersionCreatedBy() is a proxy method for getCurrentResourceVersion()->getCreatedBy()'); 127 $t->is($r2->get LastResourceVersion()->getComment(), 'bar', 'setVersionComment() defines the comment to be saved in the ResourceVersion object');127 $t->is($r2->getCurrentResourceVersion()->getComment(), 'bar', 'setVersionComment() defines the comment to be saved in the ResourceVersion object'); 128 128 $t->is($r2->getVersionComment(), 'bar', 'getVersionComment() is a proxy method for getCurrentResourceVersion()->getComment()'); 129 129 $t->is($r3->getVersionComment(), 'bar', 'getVersionComment() is a proxy method for getCurrentResourceVersion()->getComment()'); 130 $r2->setByName($test_class_title_column, 'v0', BasePeer::TYPE_FIELDNAME); 131 $r2->save(); 132 $resourceVersion = $r2->getCurrentResourceVersion(); 133 $t->is($resourceVersion->getCreatedBy(), '', 'setVersionCreatedBy() only affects the next version saved'); 134 $t->is($resourceVersion->getComment(), '', 'setVersionComment() only affects the next version saved'); 130 135 131 136 // conditional versioning … … 153 158 { 154 159 $r2->setByName($test_class_title_column, 'v0', BasePeer::TYPE_FIELDNAME); 155 $r2->addVersion( 'author1');160 $r2->addVersion(); 156 161 $r2->save(); 157 162 $t->pass('calling addVersion() on an unsaved object does not throw an exception'); … … 160 165 } 161 166 $t->is($r2->getLastResourceVersion()->getNumber(), 1, 'addVersion() creates a version object even on unsaved objects'); 167 168 $r2->setByName($test_class_title_column, 'v1', BasePeer::TYPE_FIELDNAME); 169 $r2->setVersionCreatedBy('author2'); 170 $r2->setVersionComment('baz'); 171 $r2->addVersion(); 172 $r2->save(); 173 $resourceVersion = $r2->getCurrentResourceVersion(); 174 $t->is($resourceVersion->getCreatedBy(), 'author2', 'addVersion() allows for use of setVersionCreatedBy()'); 175 $t->is($resourceVersion->getComment(), 'baz', 'addVersion() allows for use of setVersionComment()'); 176 177 $r2->setByName($test_class_title_column, 'v2', BasePeer::TYPE_FIELDNAME); 178 $r2->addVersion('author3', 'bazz'); 179 $r2->save(); 180 $resourceVersion = $r2->getCurrentResourceVersion(); 181 $t->is($resourceVersion->getCreatedBy(), 'author3', 'addVersion() accepts a version author name as first parameter'); 182 $t->is($resourceVersion->getComment(), 'bazz', 'addVersion() accepts a version comment as second parameter'); 162 183 163 184