Commit 375c470e authored by beberlei's avatar beberlei

DDC-155 - Skip __sleep in generateMethods

parent 9f9cc487
...@@ -165,7 +165,8 @@ class ProxyFactory ...@@ -165,7 +165,8 @@ class ProxyFactory
$methods = ''; $methods = '';
foreach ($class->reflClass->getMethods() as $method) { foreach ($class->reflClass->getMethods() as $method) {
if ($method->isConstructor()) { /* @var $method ReflectionMethod */
if ($method->isConstructor() || strtolower($method->getName()) == "__sleep") {
continue; continue;
} }
......
...@@ -125,9 +125,34 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase ...@@ -125,9 +125,34 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
$this->assertContains("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() protected function _getMockPersister()
{ {
$persister = $this->getMock('Doctrine\ORM\Persisters\StandardEntityPersister', array('load'), array(), '', false, false, false); $persister = $this->getMock('Doctrine\ORM\Persisters\StandardEntityPersister', array('load'), array(), '', false, false, false);
return $persister; 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