You are here

protected function TestDiscoveryTest::setupVfsWithTestClasses in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::setupVfsWithTestClasses()
  2. 9 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::setupVfsWithTestClasses()
4 calls to TestDiscoveryTest::setupVfsWithTestClasses()
TestDiscoveryTest::testGetTestClasses in core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php
@covers ::getTestClasses
TestDiscoveryTest::testGetTestClassesWithSelectedTypes in core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php
@covers ::getTestClasses
TestDiscoveryTest::testGetTestsInProfiles in core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php
@covers ::getTestClasses
TestDiscoveryTest::testScanDirectoryNoAbstract in core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php
Ensure TestDiscovery::scanDirectory() ignores certain abstract file types.

File

core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php, line 232

Class

TestDiscoveryTest
@coversDefaultClass \Drupal\Core\Test\TestDiscovery @group Test

Namespace

Drupal\Tests\Core\Test

Code

protected function setupVfsWithTestClasses() {
  vfsStream::setup('drupal');
  $test_file = <<<EOF
<?php

/**
 * Test description
 * @group example
 */
class FunctionalExampleTest {}
EOF;
  $test_profile_info = <<<EOF
name: Testing
type: profile
core_version_requirement: '*'
EOF;
  $test_module_info = <<<EOF
name: Testing
type: module
core_version_requirement: '*'
EOF;
  vfsStream::create([
    'modules' => [
      'test_module' => [
        'test_module.info.yml' => $test_module_info,
        'tests' => [
          'src' => [
            'Functional' => [
              'FunctionalExampleTest.php' => $test_file,
              'FunctionalExampleTest2.php' => str_replace([
                'FunctionalExampleTest',
                '@group example',
              ], [
                'FunctionalExampleTest2',
                '@group example2',
              ], $test_file),
            ],
            'Kernel' => [
              'KernelExampleTest3.php' => str_replace([
                'FunctionalExampleTest',
                '@group example',
              ], [
                'KernelExampleTest3',
                "@group example2\n * @group kernel\n",
              ], $test_file),
              'KernelExampleTestBase.php' => str_replace([
                'FunctionalExampleTest',
                '@group example',
              ], [
                'KernelExampleTestBase',
                '@group example2',
              ], $test_file),
              'KernelExampleTrait.php' => str_replace([
                'FunctionalExampleTest',
                '@group example',
              ], [
                'KernelExampleTrait',
                '@group example2',
              ], $test_file),
              'KernelExampleInterface.php' => str_replace([
                'FunctionalExampleTest',
                '@group example',
              ], [
                'KernelExampleInterface',
                '@group example2',
              ], $test_file),
            ],
          ],
        ],
      ],
    ],
    'profiles' => [
      'test_profile' => [
        'test_profile.info.yml' => $test_profile_info,
        'modules' => [
          'test_profile_module' => [
            'test_profile_module.info.yml' => $test_module_info,
            'tests' => [
              'src' => [
                'Kernel' => [
                  'KernelExampleTest4.php' => str_replace([
                    'FunctionalExampleTest',
                    '@group example',
                  ], [
                    'KernelExampleTest4',
                    '@group example3',
                  ], $test_file),
                ],
              ],
            ],
          ],
        ],
      ],
    ],
  ]);
}