DDC-155 - Skip __sleep in generateMethods
This commit is contained in:
parent
9f9cc4870d
commit
375c470e93
@ -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');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user