Commit 375c470e authored by beberlei's avatar beberlei

DDC-155 - Skip __sleep in generateMethods

parent 9f9cc487
......@@ -165,7 +165,8 @@ class ProxyFactory
$methods = '';
foreach ($class->reflClass->getMethods() as $method) {
if ($method->isConstructor()) {
/* @var $method ReflectionMethod */
if ($method->isConstructor() || strtolower($method->getName()) == "__sleep") {
continue;
}
......
......@@ -124,6 +124,21 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
$this->assertNotContains("class DoctrineOrmTestEntityProxy extends \\\\DoctrineOrmTestEntity", $classCode);
$this->assertContains("class DoctrineOrmTestEntityProxy extends \\DoctrineOrmTestEntity", $classCode);
}
public function testClassWithSleepProxyGeneration()
{
$className = "\Doctrine\Tests\ORM\Proxy\SleepClass";
$proxyName = "DoctrineTestsORMProxySleepClassProxy";
$classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className);
$classMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer'));
$classMetadata->setIdentifier(array('id'));
$this->_proxyFactory->generateProxyClasses(array($classMetadata));
$classCode = file_get_contents(dirname(__FILE__)."/generated/".$proxyName.".php");
$this->assertEquals(1, substr_count($classCode, 'function __sleep'));
}
protected function _getMockPersister()
{
......@@ -131,3 +146,13 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
return $persister;
}
}
class SleepClass
{
public $id;
public function __sleep()
{
return array('id');
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment