Merge pull request #1049 from deeky666/DDC-3152
[DDC-3152] Fix redeclaration of methods on entity generation update
This commit is contained in:
commit
d71159c6c5
@ -696,9 +696,9 @@ public function __construct()
|
||||
$inClass = true;
|
||||
} elseif ($token[0] == T_FUNCTION) {
|
||||
if ($tokens[$i+2][0] == T_STRING) {
|
||||
$this->staticReflection[$lastSeenClass]['methods'][] = $tokens[$i+2][1];
|
||||
$this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i+2][1]);
|
||||
} elseif ($tokens[$i+2] == "&" && $tokens[$i+3][0] == T_STRING) {
|
||||
$this->staticReflection[$lastSeenClass]['methods'][] = $tokens[$i+3][1];
|
||||
$this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i+3][1]);
|
||||
}
|
||||
} elseif (in_array($token[0], array(T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED)) && $tokens[$i+2][0] != T_FUNCTION) {
|
||||
$this->staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i+2][1], 1);
|
||||
@ -761,7 +761,7 @@ public function __construct()
|
||||
|
||||
return (
|
||||
isset($this->staticReflection[$metadata->name]) &&
|
||||
in_array($method, $this->staticReflection[$metadata->name]['methods'])
|
||||
in_array(strtolower($method), $this->staticReflection[$metadata->name]['methods'])
|
||||
);
|
||||
}
|
||||
|
||||
@ -1156,7 +1156,7 @@ public function __construct()
|
||||
if ($this->hasMethod($methodName, $metadata)) {
|
||||
return '';
|
||||
}
|
||||
$this->staticReflection[$metadata->name]['methods'][] = $methodName;
|
||||
$this->staticReflection[$metadata->name]['methods'][] = strtolower($methodName);
|
||||
|
||||
$var = sprintf('%sMethodTemplate', $type);
|
||||
$template = static::$$var;
|
||||
|
@ -169,6 +169,30 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3152
|
||||
*/
|
||||
public function testDoesNotRegenerateExistingMethodsWithDifferentCase()
|
||||
{
|
||||
$metadata = $this->generateBookEntityFixture();
|
||||
|
||||
// Workaround to change existing fields case (just to simulate the use case)
|
||||
$metadata->fieldMappings['status']['fieldName'] = 'STATUS';
|
||||
|
||||
// Should not throw a PHP fatal error
|
||||
$this->_generator->writeEntityClass($metadata, $this->_tmpDir);
|
||||
|
||||
$this->assertFileExists($this->_tmpDir . "/" . $this->_namespace . "/EntityGeneratorBook.php~");
|
||||
|
||||
$this->newInstance($metadata);
|
||||
$reflClass = new \ReflectionClass($metadata->name);
|
||||
|
||||
$this->assertTrue($reflClass->hasProperty('status'));
|
||||
$this->assertTrue($reflClass->hasProperty('STATUS'));
|
||||
$this->assertTrue($reflClass->hasMethod('getStatus'));
|
||||
$this->assertTrue($reflClass->hasMethod('setStatus'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2121
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user