fix EntityGenerator RegenerateEntityIfExists
This commit is contained in:
parent
60bacda685
commit
5cd8334897
@ -849,7 +849,7 @@ public function __construct(<params>)
|
||||
*/
|
||||
protected function hasProperty($property, ClassMetadataInfo $metadata)
|
||||
{
|
||||
if ($this->extendsClass() || class_exists($metadata->name)) {
|
||||
if ($this->extendsClass() || (!$this->isNew && class_exists($metadata->name))) {
|
||||
// don't generate property if its already on the base class.
|
||||
$reflClass = new \ReflectionClass($this->getClassToExtend() ?: $metadata->name);
|
||||
if ($reflClass->hasProperty($property)) {
|
||||
@ -878,7 +878,7 @@ public function __construct(<params>)
|
||||
*/
|
||||
protected function hasMethod($method, ClassMetadataInfo $metadata)
|
||||
{
|
||||
if ($this->extendsClass() || class_exists($metadata->name)) {
|
||||
if ($this->extendsClass() || (!$this->isNew && class_exists($metadata->name))) {
|
||||
// don't generate method if its already on the base class.
|
||||
$reflClass = new \ReflectionClass($this->getClassToExtend() ?: $metadata->name);
|
||||
|
||||
|
@ -937,6 +937,24 @@ class EntityGeneratorTest extends OrmTestCase
|
||||
$this->assertTrue($reflParameters[3]->isOptional());
|
||||
}
|
||||
|
||||
public function testRegenerateEntityClass()
|
||||
{
|
||||
$metadata = $this->generateBookEntityFixture();
|
||||
$this->loadEntityClass($metadata);
|
||||
|
||||
$className = basename(str_replace('\\', '/', $metadata->name));
|
||||
$path = $this->_tmpDir . '/' . $this->_namespace . '/' . $className . '.php';
|
||||
$classTest = file_get_contents($path);
|
||||
|
||||
$this->_generator->setRegenerateEntityIfExists(true);
|
||||
$this->_generator->setBackupExisting(false);
|
||||
|
||||
$this->_generator->writeEntityClass($metadata, $this->_tmpDir);
|
||||
$classNew = file_get_contents($path);
|
||||
|
||||
$this->assertSame($classTest,$classNew);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user