/**
* @param $className
*
* @return string
*/
private function generateProxyClass($className)
{
$proxyClassName = 'Doctrine\\Tests\\Common\\Proxy\\MagicMethodProxy\\__CG__\\' . $className;
if (class_exists($proxyClassName, false)) {
return $proxyClassName;
}
$metadata = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
$metadata->expects($this->any())->method('getName')->will($this->returnValue($className));
$metadata->expects($this->any())->method('getIdentifier')->will($this->returnValue(array('id')));
$metadata->expects($this->any())->method('getReflectionClass')->will($this->returnValue(new ReflectionClass($className)));
$metadata->expects($this->any())->method('isIdentifier')->will($this->returnCallback(function ($fieldName) {
return 'id' === $fieldName;
}));
$metadata->expects($this->any())->method('hasField')->will($this->returnCallback(function ($fieldName) {
return in_array($fieldName, array('id', 'publicField'));
}));
$metadata->expects($this->any())->method('hasAssociation')->will($this->returnValue(false));
$metadata->expects($this->any())->method('getFieldNames')->will($this->returnValue(array('id', 'publicField')));
$metadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue(array('id')));
$metadata->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array()));
$metadata->expects($this->any())->method('getTypeOfField')->will($this->returnValue('string'));
$this->proxyGenerator->generateProxyClass($metadata, $this->proxyGenerator->getProxyFileName($className));
require_once $this->proxyGenerator->getProxyFileName($className);
return $proxyClassName;
}