function TestDiscoveryTest::setupVfsWithTestClasses

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::setupVfsWithTestClasses()
  2. 8.9.x core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php \Drupal\Tests\simpletest\Unit\TestDiscoveryTest::setupVfsWithTestClasses()
  3. 8.9.x core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::setupVfsWithTestClasses()
  4. 11.x 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 234

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),
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ]);
}

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