TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
1.4 KiB

<?php
namespace TypePhp\Tests\Entity;
use PHPUnit\Framework\TestCase;
use TypePhp\Entity\ClassLikeDef;
use TypePhp\Entity\ClassDef;
use TypePhp\Entity\InterfaceDef;
use PhpParser\Modifiers;
class ClassLikeDefTest extends TestCase
{
public function testConstructWithoutNamespace(): void
{
$def = new ClassLikeDef('Foo');
$this->assertEquals('Foo', $def->name);
$this->assertEquals('', $def->namespace);
$this->assertEquals('', $def->extends);
}
public function testConstructWithNamespace(): void
{
$def = new ClassLikeDef('Foo', 'App\\Bar');
$this->assertEquals('Foo', $def->name);
$this->assertEquals('App\\Bar', $def->namespace);
}
public function testGetNamespacedNameWithoutNamespace(): void
{
$def = new ClassLikeDef('Foo');
$this->assertEquals('Foo', $def->getNamespacedName());
$this->assertEquals('Foo', $def->getNamespacedName(false));
}
public function testGetNamespacedNameSymbolic(): void
{
$def = new ClassLikeDef('Foo', 'App\\Bar');
// symbolic: backslashes → underscores → App_Bar_Foo
$this->assertEquals('App_Bar_Foo', $def->getNamespacedName(true));
}
public function testGetNamespacedNameNonSymbolic(): void
{
$def = new ClassLikeDef('Foo', 'App\\Bar');
$this->assertEquals('App\\Bar\\Foo', $def->getNamespacedName(false));
}
}