Skip to content

Commit

Permalink
Added missing test for FunctionReflector
Browse files Browse the repository at this point in the history
  • Loading branch information
asgrim committed Jul 7, 2015
1 parent 61ea1e5 commit a224087
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/unit/Reflector/FunctionReflectorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace BetterReflectionTest\Reflector;

use BetterReflection\Reflection\ReflectionFunction;
use BetterReflection\Reflector\FunctionReflector;
use BetterReflection\Reflector\Generic;
use BetterReflection\SourceLocator\StringSourceLocator;

/**
* @covers \BetterReflection\Reflector\FunctionReflector
*/
class FunctionReflectorTest extends \PHPUnit_Framework_TestCase
{
public function testReflectProxiesToGenericReflectMethod()
{
$php = '<?php function foo() {}';

$reflector = new FunctionReflector(new StringSourceLocator($php));

$reflectionMock = $this->getMockBuilder(ReflectionFunction::class)
->disableOriginalConstructor()
->getMock();

$genericReflectorMock = $this->getMockBuilder(Generic::class)
->setMethods(['reflect'])
->disableOriginalConstructor()
->getMock();

$genericReflectorMock->expects($this->once())
->method('reflect')
->will($this->returnValue($reflectionMock));

$reflectorReflection = new \ReflectionObject($reflector);
$reflectorReflectorReflection = $reflectorReflection->getProperty('reflector');
$reflectorReflectorReflection->setAccessible(true);
$reflectorReflectorReflection->setValue($reflector, $genericReflectorMock);

$reflector->reflect('foo');
}
}

0 comments on commit a224087

Please sign in to comment.