public function PHP_Token_InterfaceTest::testGetPackageNamespaceWhenExtentingFromNamespaceClass

@covers PHP_Token_INTERFACE::getPackage

File

drupal/core/vendor/phpunit/php-token-stream/Tests/Token/InterfaceTest.php, line 216

Class

PHP_Token_InterfaceTest
Tests for the PHP_Token_INTERFACE class.

Code

public function testGetPackageNamespaceWhenExtentingFromNamespaceClass() {
  $tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classExtendsNamespacedClass.php');
  $firstClassFound = false;
  foreach ($tokenStream as $token) {
    if ($firstClassFound === false && $token instanceof PHP_Token_INTERFACE) {
      $package = $token
        ->getPackage();
      $this
        ->assertSame('Baz', $token
        ->getName());
      $this
        ->assertSame('Foo\\Bar', $package['namespace']);
      $firstClassFound = true;
      continue;
    }
    if ($token instanceof PHP_Token_INTERFACE) {
      $package = $token
        ->getPackage();
      $this
        ->assertSame('Extender', $token
        ->getName());
      $this
        ->assertSame('Other\\Space', $package['namespace']);
      return;
    }
  }
  $this
    ->fail("Searching for 2 classes failed");
}