Skip to content

Commit 5cd479a

Browse files
authored
Merge pull request #198 from boundwize/more-test
Add more test on use of use statements and fqcn
2 parents c2a5ef5 + c5ef68d commit 5cd479a

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/Analyser/ClassCollectorTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,38 @@ final class Second {}
607607
$this->assertNotContains('App\Infrastructure\Service', $nodes[1]->dependencies);
608608
}
609609

610+
public function testDoesNotShareNamespaceImportsOrFullyQualifiedDependenciesAcrossNamespaceBlocks(): void
611+
{
612+
$nodes = $this->collectNodes(<<<'PHP'
613+
<?php
614+
615+
namespace App\First {
616+
use App\Infrastructure;
617+
618+
final class First
619+
{
620+
public function __construct(
621+
private Infrastructure\Service $service,
622+
private \App\Infrastructure\Repository $repository,
623+
) {
624+
}
625+
}
626+
}
627+
628+
namespace App\Second {
629+
final class Second {}
630+
}
631+
PHP);
632+
633+
$this->assertCount(2, $nodes);
634+
$this->assertContains('App\Infrastructure', $nodes[0]->dependencies);
635+
$this->assertContains('App\Infrastructure\Service', $nodes[0]->dependencies);
636+
$this->assertContains('App\Infrastructure\Repository', $nodes[0]->dependencies);
637+
$this->assertNotContains('App\Infrastructure', $nodes[1]->dependencies);
638+
$this->assertNotContains('App\Infrastructure\Service', $nodes[1]->dependencies);
639+
$this->assertNotContains('App\Infrastructure\Repository', $nodes[1]->dependencies);
640+
}
641+
610642
/**
611643
* @return iterable<string, array{string, list<string>}>
612644
*/

0 commit comments

Comments
 (0)