Utils: fixed getNiceClosureName() not processing namespaced closures properly

This commit is contained in:
Dylan K. Taylor
2019-01-26 12:08:07 +00:00
parent c66dc7b273
commit c83b7d9b69
2 changed files with 18 additions and 1 deletions

View File

@ -24,9 +24,20 @@ declare(strict_types=1);
namespace pocketmine\utils;
use PHPUnit\Framework\TestCase;
use function define;
use function defined;
class UtilsTest extends TestCase{
public function setUp(){
if(!defined('pocketmine\PATH')){
define('pocketmine\PATH', 'dummy');
}
if(!defined('pocketmine\PLUGIN_PATH')){
define('pocketmine\PLUGIN_PATH', 'dummy');
}
}
public function parseDocCommentNewlineProvider() : array{
return [
["\t/**\r\n\t * @param PlayerJoinEvent \$event\r\n\t * @priority HIGHEST\r\n\t * @notHandler\r\n\t */"],
@ -47,4 +58,9 @@ class UtilsTest extends TestCase{
self::assertArrayHasKey("priority", $tags);
self::assertEquals("HIGHEST", $tags["priority"]);
}
public function testNamespacedNiceClosureName() : void{
//be careful with this test. The closure has to be declared on the same line as the assertion.
self::assertSame('closure@' . Utils::cleanPath(__FILE__) . '#L' . __LINE__, Utils::getNiceClosureName(function(){}));
}
}