mirror of
https://github.com/danog/amp.git
synced 2024-12-02 17:37:50 +01:00
c12828081f
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.
47 lines
1.1 KiB
PHP
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());
|
|
}
|
|
}
|