You are here

private function ProxyMagicMethodsTest::generateProxyClass in Plug 7

Parameters

$className:

Return value

string

8 calls to ProxyMagicMethodsTest::generateProxyClass()
ProxyMagicMethodsTest::testClonesPrivateProperties in lib/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php
@group DCOM-175
ProxyMagicMethodsTest::testInheritedMagicClone in lib/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php
ProxyMagicMethodsTest::testInheritedMagicGet in lib/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php
ProxyMagicMethodsTest::testInheritedMagicGetByRef in lib/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php
@group DCOM-194
ProxyMagicMethodsTest::testInheritedMagicIsset in lib/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php

... See full list

File

lib/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php, line 258

Class

ProxyMagicMethodsTest
Test for behavior of proxies with inherited magic methods

Namespace

Doctrine\Tests\Common\Proxy

Code

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