1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
psalm/tests/Internal/Codebase/ClassLikesTest.php

46 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2021-12-15 04:42:37 +01:00
declare(strict_types=1);
namespace Psalm\Tests\Internal\Codebase;
use Psalm\Internal\Codebase\ClassLikes;
use Psalm\Internal\Provider\ClassLikeStorageProvider;
use Psalm\Storage\ClassLikeStorage;
use Psalm\Tests\TestCase;
final class ClassLikesTest extends TestCase
{
2022-12-16 19:58:47 +01:00
private ClassLikes $classlikes;
private ClassLikeStorageProvider $storage_provider;
public function setUp(): void
{
parent::setUp();
$this->classlikes = $this->project_analyzer->getCodebase()->classlikes;
$this->storage_provider = $this->project_analyzer->getCodebase()->classlike_storage_provider;
}
public function testWillDetectClassImplementingAliasedInterface(): void
{
2022-09-08 14:41:55 +02:00
$this->classlikes->addClassAlias('Foo', 'Bar');
$classStorage = new ClassLikeStorage('Baz');
$classStorage->class_implements['bar'] = 'Bar';
$this->storage_provider->addMore(['baz' => $classStorage]);
self::assertTrue($this->classlikes->classImplements('Baz', 'Foo'));
}
public function testWillResolveAliasedAliases(): void
{
2022-09-08 14:41:55 +02:00
$this->classlikes->addClassAlias('Foo', 'Bar');
$this->classlikes->addClassAlias('Bar', 'Baz');
$this->classlikes->addClassAlias('Baz', 'Qoo');
self::assertSame('Foo', $this->classlikes->getUnAliasedName('Qoo'));
}
}