1
0
mirror of https://github.com/danog/amp.git synced 2024-11-26 20:15:00 +01:00
amp/test/CallableMakerTest.php

47 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
2016-12-17 15:16:17 +01:00
namespace Amp\Test;
2018-06-18 20:00:01 +02:00
class CallableMaker
{
2016-12-17 15:16:17 +01:00
use \Amp\CallableMaker {
callableFromInstanceMethod as public;
callableFromStaticMethod as public;
}
2018-06-18 20:00:01 +02:00
public function instanceMethod()
{
2016-12-17 15:16:17 +01:00
return __METHOD__;
}
2018-06-18 20:00:01 +02:00
public static function staticMethod()
{
2016-12-17 15:16:17 +01:00
return __METHOD__;
}
}
class CallableMakerTest extends BaseTest
2018-06-18 20:00:01 +02:00
{
2016-12-17 15:16:17 +01:00
/** @var \Amp\Test\CallableMaker */
private $maker;
2018-06-18 20:00:01 +02:00
public function setUp()
{
2016-12-17 15:16:17 +01:00
$this->maker = new CallableMaker;
}
2018-06-18 20:00:01 +02:00
public function testCallableFromInstanceMethod()
{
2016-12-17 15:16:17 +01:00
$callable = $this->maker->callableFromInstanceMethod("instanceMethod");
$this->assertInternalType("callable", $callable);
$this->assertSame(\sprintf("%s::%s", CallableMaker::class, "instanceMethod"), $callable());
}
2018-06-18 20:00:01 +02:00
public function testCallableFromStaticMethod()
{
2016-12-17 15:16:17 +01:00
$callable = $this->maker->callableFromInstanceMethod("staticMethod");
$this->assertInternalType("callable", $callable);
$this->assertSame(\sprintf("%s::%s", CallableMaker::class, "staticMethod"), $callable());
}
}