Skip to content

Commit

Permalink
test typehits
Browse files Browse the repository at this point in the history
array and callable type hint are can not taken by parameter reflection
  • Loading branch information
koriym committed Apr 26, 2015
1 parent 9540ad2 commit b718e85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions tests/CompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\Common\Annotations\AnnotationReader;
use Ray\Aop\Exception\NotWritableException;
use TokenReflection\ReflectionClass;

class CompilerTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -190,9 +191,10 @@ public function testNoNamespace()
public function testArrayTypehintedAndCallable()
{
$class = $this->compiler->compile(FakeArrayTypehinted::class, $this->bind);
$parent = (new \ReflectionClass($class))->getParentClass()->getName();
$expected = 'Ray\Aop\FakeArrayTypehinted';
$this->assertSame($expected, $parent);
$file = file((new \ReflectionClass($class))->getFileName());
$expected = ' function returnSame(array $arrayParam, callable $callableParam)
';
$this->assertSame($expected, $file[5]);
}

public function testNotWritable()
Expand Down
4 changes: 4 additions & 0 deletions tests/Fake/FakeAnnotateClassNoName.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ public function getDouble($a)
{
return $a * 2;
}

public function returnSame($a)
{
}
}
4 changes: 2 additions & 2 deletions tests/Fake/FakeArrayTypehinted.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Ray\Aop;

class FakeArrayTypehinted implements FakeArrayInterface
class FakeArrayTypehinted
{
public function invoke(array $array, callable $callable)
public function returnSame(array $arrayParam, callable $callableParam)
{
}
}

0 comments on commit b718e85

Please sign in to comment.