* @license MIT * * @covers ProxyManager\Generator\Util\ClassGeneratorUtils */ class ClassGeneratorUtilsTest extends PHPUnit_Framework_TestCase { public function testCantAddAFinalMethod() { $classGenerator = $this->getMock('Zend\\Code\\Generator\\ClassGenerator'); $methodGenerator = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); $methodGenerator ->expects($this->once()) ->method('getName') ->willReturn('foo'); $classGenerator ->expects($this->never()) ->method('addMethodFromGenerator'); $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithFinalMethods'); ClassGeneratorUtils::addMethodIfNotFinal($reflection, $classGenerator, $methodGenerator); } public function testCanAddANotFinalMethod() { $classGenerator = $this->getMock('Zend\\Code\\Generator\\ClassGenerator'); $methodGenerator = $this->getMock('Zend\\Code\\Generator\\MethodGenerator'); $methodGenerator ->expects($this->once()) ->method('getName') ->willReturn('publicMethod'); $classGenerator ->expects($this->once()) ->method('addMethodFromGenerator'); $reflection = new ReflectionClass('ProxyManagerTestAsset\\BaseClass'); ClassGeneratorUtils::addMethodIfNotFinal($reflection, $classGenerator, $methodGenerator); } }