1
0
mirror of synced 2024-12-13 22:56:04 +03:00

[DDC-551] Added __toString() method to SQLFilter

This commit is contained in:
Alexander 2011-07-22 14:55:00 +02:00
parent 4cf63a4e83
commit 4266ab77b2
2 changed files with 24 additions and 0 deletions

View File

@ -62,5 +62,10 @@ abstract class SQLFilter
return $this->conn->quote($this->parameters[$name]['value'], $this->parameters[$name]['type']); return $this->conn->quote($this->parameters[$name]['value'], $this->parameters[$name]['type']);
} }
final function __toString()
{
return serialize($this->parameters);
}
abstract function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias); abstract function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias);
} }

View File

@ -173,6 +173,25 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals('', $filter->addFilterConstraint($targetEntity, 't1_')); $this->assertEquals('', $filter->addFilterConstraint($targetEntity, 't1_'));
} }
public function testSQLFilterToString()
{
$filter = new MyLocaleFilter($this->getMockConnection());
$filter->setParameter('locale', 'en', TYPE::STRING);
$filter->setParameter('foo', 'bar', TYPE::STRING);
$filter2 = new MyLocaleFilter($this->getMockConnection());
$filter2->setParameter('foo', 'bar', TYPE::STRING);
$filter2->setParameter('locale', 'en', TYPE::STRING);
$parameters = array(
'foo' => array('value' => 'bar', 'type' => TYPE::STRING),
'locale' => array('value' => 'en', 'type' => TYPE::STRING),
);
$this->assertEquals(serialize($parameters), ''.$filter);
$this->assertEquals(''.$filter, ''.$filter2);
}
} }
class MySoftDeleteFilter extends SQLFilter class MySoftDeleteFilter extends SQLFilter