class BackwardsCompatibilityClassLoaderTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/ClassLoader/BackwardsCompatibilityClassLoaderTest.php \Drupal\KernelTests\Core\ClassLoader\BackwardsCompatibilityClassLoaderTest

Tests Drupal\Core\ClassLoader\BackwardsCompatibilityClassLoader.

Attributes

#[CoversClass(BackwardsCompatibilityClassLoader::class)] #[Group('ClassLoader')] #[RunTestsInSeparateProcesses]

Hierarchy

Expanded class hierarchy of BackwardsCompatibilityClassLoaderTest

File

core/tests/Drupal/KernelTests/Core/ClassLoader/BackwardsCompatibilityClassLoaderTest.php, line 23

Namespace

Drupal\KernelTests\Core\ClassLoader
View source
class BackwardsCompatibilityClassLoaderTest extends KernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'module_autoload_test',
  ];
  
  /**
   * Tests that the bc layer for TranslationWrapper works.
   */
  public function testTranslationWrapper() : void {
    // @phpstan-ignore class.notFound
    $object = new TranslationWrapper('Backward compatibility');
    $this->assertInstanceOf(TranslatableMarkup::class, $object);
  }
  
  /**
   * Tests that a moved class from a module works.
   */
  public function testModuleMovedClass() : void {
    // @phpstan-ignore class.notFound
    $this->expectDeprecation('Class ' . Foo::class . ' is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0, use Drupal\\Component\\Utility\\Random instead. See https://example.com/change_record');
    // @phpstan-ignore class.notFound
    $object = new Foo();
    $this->assertInstanceOf(Random::class, $object);
  }
  
  /**
   * Tests that the BC layer for Doctrine's AnnotationException works.
   */
  public function testDoctrineException() : void {
    // @phpstan-ignore class.notFound
    $this->expectException(DoctrineAnnotationException::class);
    $this->expectExceptionMessage('[Syntax Error] test');
    $this->expectDeprecation('Class Doctrine\\Common\\Annotations\\AnnotationException is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0, use Drupal\\Component\\Annotation\\Doctrine\\AnnotationException instead. See https://www.drupal.org/node/3551049');
    throw AnnotationException::syntaxError('test');
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.