1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00
amp/test/CallableMakerTest.php
Aaron Piotrowski 5651240615 Update to promise spec v0.3
Dropped strict-types due to spec requiring weak types in callbacks.
2016-12-29 16:29:27 -06:00

40 lines
1.1 KiB
PHP

<?php
namespace Amp\Test;
class CallableMaker {
use \Amp\CallableMaker {
callableFromInstanceMethod as public;
callableFromStaticMethod as public;
}
public function instanceMethod() {
return __METHOD__;
}
public static function staticMethod() {
return __METHOD__;
}
}
class CallableMakerTest extends \PHPUnit_Framework_TestCase {
/** @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());
}
public function testCallableFromStaticMethod() {
$callable = $this->maker->callableFromInstanceMethod("staticMethod");
$this->assertInternalType("callable", $callable);
$this->assertSame(\sprintf("%s::%s", CallableMaker::class, "staticMethod"), $callable());
}
}