Author: Kris.Wallsmith
Date: 2010-02-11 19:12:56 +0100 (Thu, 11 Feb 2010)
New Revision: 27915

Added:
   branches/1.3/lib/plugins/sfPropelPlugin/test/unit/form/
   branches/1.3/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php
   branches/1.4/lib/plugins/sfPropelPlugin/test/unit/form/
   branches/1.4/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php
Modified:
   branches/1.3/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php
   
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php
   branches/1.3/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php
   branches/1.4/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php
   
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php
   branches/1.4/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php
Log:
[1.3, 1.4] fixed use of array union operator (closes #8238)

Modified: 
branches/1.3/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php
===================================================================
--- branches/1.3/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php 
2010-02-11 18:10:45 UTC (rev 27914)
+++ branches/1.3/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php 
2010-02-11 18:12:56 UTC (rev 27915)
@@ -232,11 +232,11 @@
     // update defaults for the main object
     if ($this->isNew())
     {
-      $defaults = $this->getObject()->toArray(false) + $defaults;
+      $defaults = $defaults + $this->getObject()->toArray(false);
     }
     else
     {
-      $defaults = $this->getDefaults() + $this->getObject()->toArray(false);
+      $defaults = $this->getObject()->toArray(false) + $defaults;
     }
 
     foreach ($this->embeddedForms as $name => $form)

Modified: 
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php
===================================================================
--- 
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php 
    2010-02-11 18:10:45 UTC (rev 27914)
+++ 
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php 
    2010-02-11 18:12:56 UTC (rev 27915)
@@ -3,12 +3,12 @@
 $app = 'frontend';
 include dirname(__FILE__).'/../../bootstrap/functional.php';
 
-$t = new lime_test(11);
+$t = new lime_test(13);
 
 // ->__construct()
 $t->diag('->__construct()');
 
-class DefaultValuesForm extends ArticleForm
+class NumericFieldForm extends ArticleForm
 {
   public function configure()
   {
@@ -18,10 +18,29 @@
   }
 }
 
-$form = new DefaultValuesForm();
+$form = new NumericFieldForm();
 $defaults = $form->getDefaults();
 $t->is($defaults[1], '==DEFAULT_VALUE==', '->__construct() allows 
->configure() to set defaults on numeric fields');
 
+class DefaultValuesForm extends AuthorForm
+{
+  public function configure()
+  {
+    $this->setDefault('name', 'John Doe');
+  }
+}
+
+$author = new Author();
+$form = new DefaultValuesForm($author);
+$t->is($form->getDefault('name'), 'John Doe', '->__construct() uses form 
defaults for new objects');
+
+$author = new Author();
+$author->name = 'Jacques Doe';
+$author->save();
+$form = new DefaultValuesForm($author);
+$t->is($form->getDefault('name'), 'Jacques Doe', '->__construct() uses object 
value as a default for existing objects');
+$author->delete();
+
 // ->embedRelation()
 $t->diag('->embedRelation()');
 

Modified: 
branches/1.3/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php
===================================================================
--- branches/1.3/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php     
2010-02-11 18:10:45 UTC (rev 27914)
+++ branches/1.3/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php     
2010-02-11 18:12:56 UTC (rev 27915)
@@ -191,11 +191,11 @@
     // update defaults for the main object
     if ($this->isNew())
     {
-      $this->setDefaults($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME) 
+ $this->getDefaults());
+      $this->setDefaults($this->getDefaults() + 
$this->getObject()->toArray(BasePeer::TYPE_FIELDNAME));
     }
     else
     {
-      $this->setDefaults($this->getDefaults() + 
$this->getObject()->toArray(BasePeer::TYPE_FIELDNAME));
+      $this->setDefaults($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME) 
+ $this->getDefaults());
     }
   }
 

Added: 
branches/1.3/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php
===================================================================
--- branches/1.3/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php 
                        (rev 0)
+++ branches/1.3/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php 
2010-02-11 18:12:56 UTC (rev 27915)
@@ -0,0 +1,29 @@
+<?php
+
+$app = 'frontend';
+include dirname(__FILE__).'/../../bootstrap/functional.php';
+include $configuration->getSymfonyLibDir().'/vendor/lime/lime.php';
+
+$t = new lime_test(2);
+
+// ->__construct()
+$t->diag('->__construct()');
+
+class DefaultValuesForm extends AuthorForm
+{
+  public function configure()
+  {
+    $this->setDefault('name', 'John Doe');
+  }
+}
+
+$author = new Author();
+$form = new DefaultValuesForm($author);
+$t->is($form->getDefault('name'), 'John Doe', '->__construct() uses form 
defaults for new objects');
+
+$author = new Author();
+$author->setName('Jacques Doe');
+$author->save();
+$form = new DefaultValuesForm($author);
+$t->is($form->getDefault('name'), 'Jacques Doe', '->__construct() uses object 
value as a default for existing objects');
+$author->delete();


Property changes on: 
branches/1.3/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Modified: 
branches/1.4/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php
===================================================================
--- branches/1.4/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php 
2010-02-11 18:10:45 UTC (rev 27914)
+++ branches/1.4/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php 
2010-02-11 18:12:56 UTC (rev 27915)
@@ -232,11 +232,11 @@
     // update defaults for the main object
     if ($this->isNew())
     {
-      $defaults = $this->getObject()->toArray(false) + $defaults;
+      $defaults = $defaults + $this->getObject()->toArray(false);
     }
     else
     {
-      $defaults = $this->getDefaults() + $this->getObject()->toArray(false);
+      $defaults = $this->getObject()->toArray(false) + $defaults;
     }
 
     foreach ($this->embeddedForms as $name => $form)

Modified: 
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php
===================================================================
--- 
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php 
    2010-02-11 18:10:45 UTC (rev 27914)
+++ 
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php 
    2010-02-11 18:12:56 UTC (rev 27915)
@@ -3,12 +3,12 @@
 $app = 'frontend';
 include dirname(__FILE__).'/../../bootstrap/functional.php';
 
-$t = new lime_test(11);
+$t = new lime_test(13);
 
 // ->__construct()
 $t->diag('->__construct()');
 
-class DefaultValuesForm extends ArticleForm
+class NumericFieldForm extends ArticleForm
 {
   public function configure()
   {
@@ -18,10 +18,29 @@
   }
 }
 
-$form = new DefaultValuesForm();
+$form = new NumericFieldForm();
 $defaults = $form->getDefaults();
 $t->is($defaults[1], '==DEFAULT_VALUE==', '->__construct() allows 
->configure() to set defaults on numeric fields');
 
+class DefaultValuesForm extends AuthorForm
+{
+  public function configure()
+  {
+    $this->setDefault('name', 'John Doe');
+  }
+}
+
+$author = new Author();
+$form = new DefaultValuesForm($author);
+$t->is($form->getDefault('name'), 'John Doe', '->__construct() uses form 
defaults for new objects');
+
+$author = new Author();
+$author->name = 'Jacques Doe';
+$author->save();
+$form = new DefaultValuesForm($author);
+$t->is($form->getDefault('name'), 'Jacques Doe', '->__construct() uses object 
value as a default for existing objects');
+$author->delete();
+
 // ->embedRelation()
 $t->diag('->embedRelation()');
 

Modified: 
branches/1.4/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php
===================================================================
--- branches/1.4/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php     
2010-02-11 18:10:45 UTC (rev 27914)
+++ branches/1.4/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php     
2010-02-11 18:12:56 UTC (rev 27915)
@@ -191,11 +191,11 @@
     // update defaults for the main object
     if ($this->isNew())
     {
-      $this->setDefaults($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME) 
+ $this->getDefaults());
+      $this->setDefaults($this->getDefaults() + 
$this->getObject()->toArray(BasePeer::TYPE_FIELDNAME));
     }
     else
     {
-      $this->setDefaults($this->getDefaults() + 
$this->getObject()->toArray(BasePeer::TYPE_FIELDNAME));
+      $this->setDefaults($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME) 
+ $this->getDefaults());
     }
   }
 

Added: 
branches/1.4/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php
===================================================================
--- branches/1.4/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php 
                        (rev 0)
+++ branches/1.4/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php 
2010-02-11 18:12:56 UTC (rev 27915)
@@ -0,0 +1,29 @@
+<?php
+
+$app = 'frontend';
+include dirname(__FILE__).'/../../bootstrap/functional.php';
+include $configuration->getSymfonyLibDir().'/vendor/lime/lime.php';
+
+$t = new lime_test(2);
+
+// ->__construct()
+$t->diag('->__construct()');
+
+class DefaultValuesForm extends AuthorForm
+{
+  public function configure()
+  {
+    $this->setDefault('name', 'John Doe');
+  }
+}
+
+$author = new Author();
+$form = new DefaultValuesForm($author);
+$t->is($form->getDefault('name'), 'John Doe', '->__construct() uses form 
defaults for new objects');
+
+$author = new Author();
+$author->setName('Jacques Doe');
+$author->save();
+$form = new DefaultValuesForm($author);
+$t->is($form->getDefault('name'), 'Jacques Doe', '->__construct() uses object 
value as a default for existing objects');
+$author->delete();


Property changes on: 
branches/1.4/lib/plugins/sfPropelPlugin/test/unit/form/sfFormPropelTest.php
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to