1
0
mirror of https://github.com/danog/amp.git synced 2024-11-26 20:15:00 +01:00
amp/test/CallableMakerTest.php
Niklas Keller c12828081f Fix exceptions bubbling from Coroutine::__destruct
This has been an edge case potentially hiding some exceptions. The tests have been refactored to error if the loop has watchers leaking from one test to another test.
2019-05-31 11:38:02 -05:00

47 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 BaseTest
{
/** @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());
}
}