Skip to content

Commit

Permalink
Modify way of make test and create a case of test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
malukenho committed Oct 23, 2014
1 parent cd53b44 commit 05fd973
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions tests/ProxyManagerTest/Generator/Util/ClassGeneratorUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,39 @@ class ClassGeneratorUtilsTest extends PHPUnit_Framework_TestCase
{
public function testCantAddAFinalMethod()
{
$classGenerator = $this->getMock('Zend\\Code\\Generator\\ClassGenerator');
$classGenerator = $this->getMock('Zend\\Code\\Generator\\ClassGenerator');
$methodGenerator = $this->getMock('Zend\\Code\\Generator\\MethodGenerator');

$methodGenerator
->expects($this->any())
->expects($this->once())
->method('getName')
->willReturn('foo');

$classGenerator
->expects($this->never())
->method('addMethodFromGenerator');

$reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithFinalMethods');

$this->assertFalse(
ClassGeneratorUtils::addMethodIfNotFinal($reflection, $classGenerator, $methodGenerator)
);
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);
}
}

0 comments on commit 05fd973

Please sign in to comment.