Skip to content

Commit

Permalink
Adding failing test for doctrine#259 (non-recognized 'callable' type …
Browse files Browse the repository at this point in the history
…hint)
  • Loading branch information
Ocramius committed Mar 7, 2013
1 parent e211821 commit a4a5b10
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/Doctrine/Tests/Common/Proxy/CallableTypeHintClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Doctrine\Tests\Common\Proxy;

/**
* Test asset class
*/
class CallableTypeHintClass
{
/**
* @param callable $foo
*/
public function call(callable $foo)
{
}
}
20 changes: 20 additions & 0 deletions tests/Doctrine/Tests/Common/Proxy/ProxyClassGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@ public function testClassWithSleepProxyGeneration()
$this->assertEquals(1, substr_count($classCode, 'parent::__sleep()'));
}

public function testClassWithCallableTypeHintOnProxiedMethod()
{
if (!class_exists('Doctrine\Tests\Common\ProxyProxy\__CG__\CallableTypeHintClass', false)) {
$metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$reflClass = new ReflectionClass('Doctrine\Tests\Common\Proxy\CallableTypeHintClass');
$proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true);

$metadata->expects($this->any())->method('getReflectionClass')->will($this->returnValue($reflClass));
$metadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue(array('id')));
$metadata->expects($this->any())->method('getName')->will($this->returnValue($reflClass->getName()));

$proxyGenerator->generateProxyClass($metadata);
require_once $proxyGenerator->getProxyFileName($metadata->getName());
}

$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyCallableTypeHintClass.php');

$this->assertEquals(1, substr_count($classCode, 'call(callable $foo)'));
}

public function testClassWithInvalidTypeHintOnProxiedMethod()
{
$className = 'Doctrine\Tests\Common\Proxy\InvalidTypeHintClass';
Expand Down

0 comments on commit a4a5b10

Please sign in to comment.