1
0
mirror of synced 2025-01-18 22:41:43 +03:00

DDC-155 - Skip __sleep in generateMethods

This commit is contained in:
beberlei 2010-01-06 14:12:27 +00:00
parent 9f9cc4870d
commit 375c470e93
2 changed files with 27 additions and 1 deletions

View File

@ -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;
}

View File

@ -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');
}
}