protected function doTest($source, array $expectedTokens = array(), array $observedKinds = array())
{
$tokens = Tokens::fromCode($source);
$this->assertSame(count($expectedTokens), array_sum(array_map(function ($item) {
return count($item);
}, $tokens->findGivenKind(array_unique(array_merge($observedKinds, array_values($expectedTokens)))))));
foreach ($expectedTokens as $index => $tokenId) {
$this->assertSame(CT::has($tokenId) ? CT::getName($tokenId) : token_name($tokenId), $tokens[$index]->getName(), sprintf('Token kind should be the same at index %d.', $index));
$this->assertSame($tokenId, $tokens[$index]->getId());
}
}