2016-12-29 21:09:49 +01:00
|
|
|
<?php
|
2016-12-17 15:16:17 +01:00
|
|
|
|
|
|
|
namespace Amp\Test;
|
|
|
|
|
|
|
|
class CallableMaker {
|
|
|
|
use \Amp\CallableMaker {
|
|
|
|
callableFromInstanceMethod as public;
|
|
|
|
callableFromStaticMethod as public;
|
|
|
|
}
|
2017-03-11 14:57:03 +01:00
|
|
|
|
2016-12-17 15:16:17 +01:00
|
|
|
public function instanceMethod() {
|
|
|
|
return __METHOD__;
|
|
|
|
}
|
2017-03-11 14:57:03 +01:00
|
|
|
|
2016-12-17 15:16:17 +01:00
|
|
|
public static function staticMethod() {
|
|
|
|
return __METHOD__;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:57:03 +01:00
|
|
|
class CallableMakerTest extends \PHPUnit\Framework\TestCase {
|
2016-12-17 15:16:17 +01:00
|
|
|
/** @var \Amp\Test\CallableMaker */
|
|
|
|
private $maker;
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
$this->maker = new CallableMaker;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCallableFromInstanceMethod() {
|
|
|
|
$callable = $this->maker->callableFromInstanceMethod("instanceMethod");
|
|
|
|
$this->assertInternalType("callable", $callable);
|
|
|
|
$this->assertSame(\sprintf("%s::%s", CallableMaker::class, "instanceMethod"), $callable());
|
|
|
|
}
|
2017-03-11 14:57:03 +01:00
|
|
|
|
2016-12-17 15:16:17 +01:00
|
|
|
public function testCallableFromStaticMethod() {
|
|
|
|
$callable = $this->maker->callableFromInstanceMethod("staticMethod");
|
|
|
|
$this->assertInternalType("callable", $callable);
|
|
|
|
$this->assertSame(\sprintf("%s::%s", CallableMaker::class, "staticMethod"), $callable());
|
|
|
|
}
|
|
|
|
}
|