Permalink
Browse files

Adding failing test for doctrine/common#259 (non-recognized 'callable…

…' type hint)
  • Loading branch information...
1 parent e211821 commit a4a5b108984e86c831b2c2dafa954b3fe5ea1b83 @Ocramius Ocramius committed Mar 7, 2013
@@ -0,0 +1,16 @@
+<?php
+
+namespace Doctrine\Tests\Common\Proxy;
+
+/**
+ * Test asset class
+ */
+class CallableTypeHintClass
+{
+ /**
+ * @param callable $foo
+ */
+ public function call(callable $foo)
+ {
+ }
+}
@@ -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';

0 comments on commit a4a5b10

Please sign in to comment.