Author: Kris.Wallsmith
Date: 2010-02-08 15:50:13 +0100 (Mon, 08 Feb 2010)
New Revision: 27736
Added:
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/validator/
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/validator/
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
Modified:
branches/1.3/lib/plugins/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php
branches/1.4/lib/plugins/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php
Log:
[1.3, 1.4] fixed sfValidatorDoctrineChoice in cloned forms (embedForEach)
doesn't function correctly (closes #8198)
Modified:
branches/1.3/lib/plugins/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php
===================================================================
---
branches/1.3/lib/plugins/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php
2010-02-08 13:50:23 UTC (rev 27735)
+++
branches/1.3/lib/plugins/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php
2010-02-08 14:50:13 UTC (rev 27736)
@@ -53,6 +53,15 @@
*/
protected function doClean($value)
{
+ if ($query = $this->getOption('query'))
+ {
+ $query = clone $query;
+ }
+ else
+ {
+ $query =
Doctrine_Core::getTable($this->getOption('model'))->createQuery();
+ }
+
if ($this->getOption('multiple'))
{
if (!is_array($value))
@@ -77,10 +86,6 @@
throw new sfValidatorError($this, 'max', array('count' => $count,
'max' => $this->getOption('max')));
}
- if (!$query = $this->getOption('query'))
- {
- $query =
Doctrine_Core::getTable($this->getOption('model'))->createQuery();
- }
$query->andWhereIn(sprintf('%s.%s', $query->getRootAlias(),
$this->getColumn()), $value);
if ($query->count() != count($value))
@@ -90,10 +95,6 @@
}
else
{
- if (!$query = $this->getOption('query'))
- {
- $query =
Doctrine_Core::getTable($this->getOption('model'))->createQuery();
- }
$query->andWhere(sprintf('%s.%s = ?', $query->getRootAlias(),
$this->getColumn()), $value);
if (!$query->count())
Added:
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
===================================================================
---
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
(rev 0)
+++
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
2010-02-08 14:50:13 UTC (rev 27736)
@@ -0,0 +1,18 @@
+<?php
+
+$app = 'frontend';
+$fixtures = 'fixtures/fixtures.yml';
+include dirname(__FILE__).'/../../bootstrap/functional.php';
+
+$t = new lime_test(1);
+
+// ->clean()
+$t->diag('->clean()');
+
+$query = Doctrine_Core::getTable('Author')->createQuery();
+$validator = new sfValidatorDoctrineChoice(array('model' => 'Author', 'query'
=> $query));
+
+$author =
Doctrine_Core::getTable('Author')->createQuery()->limit(1)->fetchOne();
+$validator->clean($author->id);
+
+$t->is(trim($query->getDql()), 'FROM Author', '->clean() does not change the
supplied query object');
Property changes on:
branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified:
branches/1.4/lib/plugins/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php
===================================================================
---
branches/1.4/lib/plugins/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php
2010-02-08 13:50:23 UTC (rev 27735)
+++
branches/1.4/lib/plugins/sfDoctrinePlugin/lib/validator/sfValidatorDoctrineChoice.class.php
2010-02-08 14:50:13 UTC (rev 27736)
@@ -53,6 +53,15 @@
*/
protected function doClean($value)
{
+ if ($query = $this->getOption('query'))
+ {
+ $query = clone $query;
+ }
+ else
+ {
+ $query =
Doctrine_Core::getTable($this->getOption('model'))->createQuery();
+ }
+
if ($this->getOption('multiple'))
{
if (!is_array($value))
@@ -77,10 +86,6 @@
throw new sfValidatorError($this, 'max', array('count' => $count,
'max' => $this->getOption('max')));
}
- if (!$query = $this->getOption('query'))
- {
- $query =
Doctrine_Core::getTable($this->getOption('model'))->createQuery();
- }
$query->andWhereIn(sprintf('%s.%s', $query->getRootAlias(),
$this->getColumn()), $value);
if ($query->count() != count($value))
@@ -90,10 +95,6 @@
}
else
{
- if (!$query = $this->getOption('query'))
- {
- $query =
Doctrine_Core::getTable($this->getOption('model'))->createQuery();
- }
$query->andWhere(sprintf('%s.%s = ?', $query->getRootAlias(),
$this->getColumn()), $value);
if (!$query->count())
Added:
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
===================================================================
---
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
(rev 0)
+++
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.php
2010-02-08 14:50:13 UTC (rev 27736)
@@ -0,0 +1,18 @@
+<?php
+
+$app = 'frontend';
+$fixtures = 'fixtures/fixtures.yml';
+include dirname(__FILE__).'/../../bootstrap/functional.php';
+
+$t = new lime_test(1);
+
+// ->clean()
+$t->diag('->clean()');
+
+$query = Doctrine_Core::getTable('Author')->createQuery();
+$validator = new sfValidatorDoctrineChoice(array('model' => 'Author', 'query'
=> $query));
+
+$author =
Doctrine_Core::getTable('Author')->createQuery()->limit(1)->fetchOne();
+$validator->clean($author->id);
+
+$t->is(trim($query->getDql()), 'FROM Author', '->clean() does not change the
supplied query object');
Property changes on:
branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/validator/sfValidatorDoctrineChoiceTest.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.