-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from sensiolabs-de/bugfix/resovle-class-names…
…cope Bugfix: classes in other namespaces are resolved in same namespace
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\SensioLabs\Deptrac\AstRunner; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SensioLabs\Deptrac\AstRunner\AstMap\AstDependency; | ||
use SensioLabs\Deptrac\AstRunner\AstMap\AstFileReference; | ||
use SensioLabs\Deptrac\AstRunner\Resolver\NameScope; | ||
|
||
class NameScopeTest extends TestCase | ||
{ | ||
public function testResolveStringName(): void | ||
{ | ||
$fileReference = new AstFileReference('baz.php'); | ||
$fileReference->addDependency(AstDependency::useStmt('FooBar\OtherNamespace\OtherNamespaceClass', 1)); | ||
$classReference = $fileReference->addClassReference('FooBar\Baz'); | ||
|
||
$nameScope = new NameScope($classReference); | ||
|
||
static::assertSame('FooBar\SameNamespaceClass', $nameScope->resolveStringName('SameNamespaceClass')); | ||
static::assertSame('FooBar\OtherNamespace\OtherNamespaceClass', $nameScope->resolveStringName('OtherNamespaceClass')); | ||
} | ||
} |