1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00
amp/test/CallableMakerTest.php

40 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2016-12-17 15:16:17 +01:00
namespace Amp\Test;
class CallableMaker {
use \Amp\CallableMaker {
callableFromInstanceMethod as public;
callableFromStaticMethod as public;
}
2016-12-17 15:16:17 +01:00
public function instanceMethod() {
return __METHOD__;
}
2016-12-17 15:16:17 +01:00
public static function staticMethod() {
return __METHOD__;
}
}
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());
}
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());
}
}