You are here

protected function TestDiscoveryTest::setupVfsWithTestClasses in Drupal 8

Same name in this branch
  1. 8 core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php \Drupal\Tests\Core\Test\TestDiscoveryTest::setupVfsWithTestClasses()
  2. 8 core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php \Drupal\Tests\simpletest\Unit\TestDiscoveryTest::setupVfsWithTestClasses()
3 calls to TestDiscoveryTest::setupVfsWithTestClasses()
TestDiscoveryTest::testGetTestClasses in core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php
@covers ::getTestClasses
TestDiscoveryTest::testGetTestClassesWithSelectedTypes in core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php
@covers ::getTestClasses
TestDiscoveryTest::testGetTestsInProfiles in core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php
@covers ::getTestClasses

File

core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php, line 22

Class

TestDiscoveryTest
@coversDefaultClass \Drupal\simpletest\TestDiscovery

Namespace

Drupal\Tests\simpletest\Unit

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: 8.x
EOF;
  $test_module_info = <<<EOF
name: Testing
type: module
core: 8.x
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),
                ],
              ],
            ],
          ],
        ],
      ],
    ],
  ]);
}