* Dariusz RumiƄski * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\Tests\Tokenizer\Analyzer; use PhpCsFixer\Tests\TestCase; use PhpCsFixer\Tokenizer\Analyzer\Analysis\NamespaceAnalysis; use PhpCsFixer\Tokenizer\Analyzer\NamespacesAnalyzer; use PhpCsFixer\Tokenizer\Tokens; /** * @author VeeWee * * @internal * * @covers \PhpCsFixer\Tokenizer\Analyzer\NamespacesAnalyzer */ final class NamespacesAnalyzerTest extends TestCase { /** * @param list $expected * * @dataProvider provideNamespacesCases */ public function testNamespaces(string $code, array $expected): void { $tokens = Tokens::fromCode($code); $analyzer = new NamespacesAnalyzer(); self::assertSame( serialize($expected), serialize($analyzer->getDeclarations($tokens)) ); } public static function provideNamespacesCases(): iterable { yield ['getNamespaceAt($tokens, $index)) ); } /** * @return iterable */ public static function provideGetNamespaceAtCases(): iterable { yield [ 'expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Token index 666 does not exist.'); $analyzer = new NamespacesAnalyzer(); $analyzer->getNamespaceAt(new Tokens(), 666); } }