function KernelTestBaseTest::testSetUp

Same name in this branch
  1. 10 core/modules/pgsql/tests/src/Kernel/pgsql/KernelTestBaseTest.php \Drupal\Tests\pgsql\Kernel\pgsql\KernelTestBaseTest::testSetUp()
Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()
  2. 8.9.x core/modules/simpletest/src/Tests/KernelTestBaseTest.php \Drupal\simpletest\Tests\KernelTestBaseTest::testSetUp()
  3. 8.9.x core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()
  4. 11.x core/modules/pgsql/tests/src/Kernel/pgsql/KernelTestBaseTest.php \Drupal\Tests\pgsql\Kernel\pgsql\KernelTestBaseTest::testSetUp()
  5. 11.x core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()

@covers ::setUp

File

core/tests/Drupal/KernelTests/KernelTestBaseTest.php, line 70

Class

KernelTestBaseTest
@coversDefaultClass \Drupal\KernelTests\KernelTestBase

Namespace

Drupal\KernelTests

Code

public function testSetUp() : void {
    $this->assertTrue($this->container
        ->has('request_stack'));
    $this->assertTrue($this->container
        ->initialized('request_stack'));
    $request = $this->container
        ->get('request_stack')
        ->getCurrentRequest();
    $this->assertNotEmpty($request);
    $this->assertEquals('/', $request->getPathInfo());
    $this->assertSame($request, \Drupal::request());
    $this->assertEquals($this, $GLOBALS['conf']['container_service_providers']['test']);
    $GLOBALS['destroy-me'] = TRUE;
    $this->assertArrayHasKey('destroy-me', $GLOBALS);
    $database = $this->container
        ->get('database');
    $database->schema()
        ->createTable('foo', [
        'fields' => [
            'number' => [
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
            ],
        ],
    ]);
    $this->assertTrue($database->schema()
        ->tableExists('foo'));
    $this->assertNotNull(FileCacheFactory::getPrefix());
}

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