Changeset 8531
- Timestamp:
- 04/18/08 19:15:38 (7 months ago)
- Files:
-
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ObjectBuilder.php (modified) (3 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/test/classes/propel/GeneratedObjectTest.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/test/sfTestBrowser.class.php (modified) (3 diffs)
- branches/dwhittle/1.1/lib/util/sfParameterHolder.class.php (modified) (1 diff)
- branches/dwhittle/1.1/lib/validator/sfValidatorFile.class.php (modified) (2 diffs)
- branches/dwhittle/1.1/test/unit/validator/sfValidatorFileTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ObjectBuilder.php
r8133 r8531 2 2 3 3 /* 4 * $Id: PHP5ObjectBuilder.php 10 17 2008-03-27 17:58:03Z hans $4 * $Id: PHP5ObjectBuilder.php 1028 2008-04-18 10:29:27Z hans $ 5 5 * 6 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 3170 3170 "; 3171 3171 3172 $pkcols = array(); 3173 foreach ($table->getColumns() as $pkcol) { 3174 if ($pkcol->isPrimaryKey()) { 3175 $pkcols[] = $pkcol->getName(); 3176 } 3177 } 3178 3172 $autoIncCols = array(); 3179 3173 foreach ($table->getColumns() as $col) { 3180 if (!in_array($col->getName(), $pkcols)) { 3174 /* @var $col Column */ 3175 if ($col->isAutoIncrement()) { 3176 $autoIncCols[] = $col; 3177 } 3178 } 3179 3180 foreach ($table->getColumns() as $col) { 3181 if (!in_array($col, $autoIncCols)) { 3181 3182 $script .= " 3182 3183 \$copyObj->set".$col->getPhpName()."(\$this->".strtolower($col->getName())."); … … 3232 3233 "; 3233 3234 3234 3235 foreach ($table->getColumns() as $col) {3236 if ($col->isPrimaryKey()) {3235 // Note: we're no longer resetting non-autoincrement primary keys to default values 3236 // due to: http://propel.phpdb.org/trac/ticket/618 3237 foreach ($autoIncCols as $col) { 3237 3238 $coldefval = $col->getPhpDefaultValue(); 3238 3239 $coldefval = var_export($coldefval, true); 3239 3240 $script .= " 3240 \$copyObj->set".$col->getPhpName() ."($coldefval); // this is a pkey column, so set to default value 3241 "; 3242 } // if col->isPrimaryKey 3241 \$copyObj->set".$col->getPhpName() ."($coldefval); // this is a auto-increment column, so set to default value 3242 "; 3243 3243 } // foreach 3244 3244 $script .= " branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/test/classes/propel/GeneratedObjectTest.php
r8331 r8531 1 1 <?php 2 2 /* 3 * $Id: GeneratedObjectTest.php 10 19 2008-04-03 20:35:22Z soenke$3 * $Id: GeneratedObjectTest.php 1028 2008-04-18 10:29:27Z hans $ 4 4 * 5 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 884 884 $this->assertEquals($emp->getBookstoreEmployeeAccount()->getLogin(), $e2->getBookstoreEmployeeAccount()->getLogin()); 885 885 } 886 887 /** 888 * Test copying when an object has composite primary key. 889 * @link http://propel.phpdb.org/trac/ticket/618 890 */ 891 public function testCopy_CompositePK() 892 { 893 $br = new BookReader(); 894 $br->setName("TestReader"); 895 $br->save(); 896 $br->copy(); 897 898 $b = new Book(); 899 $b->setTitle("TestBook"); 900 $b->setISBN("XX-XX-XX-XX"); 901 $b->save(); 902 903 $op = new BookOpinion(); 904 $op->setBookReader($br); 905 $op->setBook($b); 906 $op->setRating(10); 907 $op->setRecommendToFriend(true); 908 $op->save(); 909 910 911 $br2 = $br->copy(true); 912 913 $this->assertNull($br2->getId()); 914 915 $opinions = $br2->getBookOpinions(); 916 $this->assertEquals(1, count($opinions), "Expected to have a related BookOpinion after copy()"); 917 918 // We DO expect the reader_id to be null 919 $this->assertNull($opinions[0]->getReaderId()); 920 // but we DO NOT expect the book_id to be null 921 $this->assertEquals($op->getBookId(), $opinions[0]->getBookId()); 922 } 886 923 887 924 /** branches/dwhittle/1.1/lib/test/sfTestBrowser.class.php
r8511 r8531 474 474 } 475 475 476 if (!defined('E_RECOVERABLE_ERROR')) 477 { 478 define('E_RECOVERABLE_ERROR', 4096); 479 } 480 476 481 /** 477 482 * Error handler for the current test browser instance. … … 489 494 } 490 495 491 $msg = sprintf('PHP send a "% s" error at %s line %s (%s)', '%s', $errfile, $errline, $errstr);496 $msg = sprintf('PHP send a "%%s" error at %s line %s (%s)', $errfile, $errline, $errstr); 492 497 switch ($errno) 493 498 { … … 501 506 throw new Exception(sprintf($msg, 'strict')); 502 507 break; 508 case E_RECOVERABLE_ERROR: 509 throw new Exception(sprintf($msg, 'catchable')); 510 break; 503 511 } 504 512 } branches/dwhittle/1.1/lib/util/sfParameterHolder.class.php
r7797 r8531 98 98 else 99 99 { 100 return sfToolkit:: getArrayValueForPath($this->parameters, $name);100 return sfToolkit::hasArrayValueForPath($this->parameters, $name); 101 101 } 102 102 branches/dwhittle/1.1/lib/validator/sfValidatorFile.class.php
r7918 r8531 69 69 'image/gif', 70 70 ))); 71 $this->addOption('validated_file_class', 'sfValidatedFile'); 71 72 72 73 $this->addMessage('max_size', 'File is too large (maximum is %max_size% bytes).'); … … 152 153 } 153 154 154 return new sfValidatedFile($value['name'], $mimeType, $value['tmp_name'], $value['size']); 155 $class = $this->getOption('validated_file_class'); 156 157 return new $class($value['name'], $mimeType, $value['tmp_name'], $value['size']); 155 158 } 156 159 branches/dwhittle/1.1/test/unit/validator/sfValidatorFileTest.php
r6962 r8531 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(5 8, new lime_output_color());13 $t = new lime_test(59, new lime_output_color()); 14 14 15 15 $tmpDir = sfToolkit::getTmpDir(); … … 128 128 $t->is($f->getSize(), strlen($content), '->clean() returns a sfValidatedFile with a computed file size if the size is not passed in the initial value'); 129 129 $t->is($f->getType(), 'text/plain', '->clean() returns a sfValidatedFile with a guessed content type'); 130 131 class myValidatedFile extends sfValidatedFile 132 { 133 } 134 135 $v->setOption('validated_file_class', 'myValidatedFile'); 136 $f = $v->clean(array('tmp_name' => $tmpDir.'/test.txt')); 137 $t->ok($f instanceof myValidatedFile, '->clean() can take a "validated_file_class" option'); 130 138 131 139 foreach (array(UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION) as $error)