Development

Changeset 8531

You must first sign up to be able to contribute.

Changeset 8531

Show
Ignore:
Timestamp:
04/18/08 19:15:38 (7 months ago)
Author:
dwhittle
Message:

dwhittle: merged changes to branch

Files:

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  
    22 
    33/* 
    4  *  $Id: PHP5ObjectBuilder.php 1017 2008-03-27 17:58:03Z hans $ 
     4 *  $Id: PHP5ObjectBuilder.php 1028 2008-04-18 10:29:27Z hans $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    31703170"; 
    31713171 
    3172     $pkcols = array(); 
    3173     foreach ($table->getColumns() as $pkcol) { 
    3174       if ($pkcol->isPrimaryKey()) { 
    3175         $pkcols[] = $pkcol->getName(); 
    3176       } 
    3177     } 
    3178  
     3172    $autoIncCols = array(); 
    31793173    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)) { 
    31813182        $script .= " 
    31823183    \$copyObj->set".$col->getPhpName()."(\$this->".strtolower($col->getName())."); 
     
    32323233"; 
    32333234 
    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) { 
    32373238        $coldefval = $col->getPhpDefaultValue(); 
    32383239        $coldefval = var_export($coldefval, true); 
    32393240        $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"; 
    32433243    } // foreach 
    32443244    $script .= " 
  • branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/test/classes/propel/GeneratedObjectTest.php

    r8331 r8531  
    11<?php 
    22/* 
    3  *  $Id: GeneratedObjectTest.php 1019 2008-04-03 20:35:22Z soenke
     3 *  $Id: GeneratedObjectTest.php 1028 2008-04-18 10:29:27Z hans
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    884884    $this->assertEquals($emp->getBookstoreEmployeeAccount()->getLogin(), $e2->getBookstoreEmployeeAccount()->getLogin()); 
    885885  } 
     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  } 
    886923 
    887924  /** 
  • branches/dwhittle/1.1/lib/test/sfTestBrowser.class.php

    r8511 r8531  
    474474} 
    475475 
     476if (!defined('E_RECOVERABLE_ERROR')) 
     477{ 
     478  define('E_RECOVERABLE_ERROR', 4096); 
     479} 
     480 
    476481/** 
    477482 * Error handler for the current test browser instance. 
     
    489494  } 
    490495 
    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); 
    492497  switch ($errno) 
    493498  { 
     
    501506      throw new Exception(sprintf($msg, 'strict')); 
    502507      break; 
     508    case E_RECOVERABLE_ERROR: 
     509      throw new Exception(sprintf($msg, 'catchable')); 
     510      break; 
    503511  } 
    504512} 
  • branches/dwhittle/1.1/lib/util/sfParameterHolder.class.php

    r7797 r8531  
    9898    else 
    9999    { 
    100       return sfToolkit::getArrayValueForPath($this->parameters, $name); 
     100      return sfToolkit::hasArrayValueForPath($this->parameters, $name); 
    101101    } 
    102102 
  • branches/dwhittle/1.1/lib/validator/sfValidatorFile.class.php

    r7918 r8531  
    6969        'image/gif', 
    7070    ))); 
     71    $this->addOption('validated_file_class', 'sfValidatedFile'); 
    7172 
    7273    $this->addMessage('max_size', 'File is too large (maximum is %max_size% bytes).'); 
     
    152153    } 
    153154 
    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']); 
    155158  } 
    156159 
  • branches/dwhittle/1.1/test/unit/validator/sfValidatorFileTest.php

    r6962 r8531  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(58, new lime_output_color()); 
     13$t = new lime_test(59, new lime_output_color()); 
    1414 
    1515$tmpDir = sfToolkit::getTmpDir(); 
     
    128128$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'); 
    129129$t->is($f->getType(), 'text/plain', '->clean() returns a sfValidatedFile with a guessed content type'); 
     130 
     131class 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'); 
    130138 
    131139foreach (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)