You are here

public function KernelTestBaseTest::testSetUp in Zircon Profile 8

Same name in this branch
  1. 8 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()
  2. 8 core/modules/simpletest/src/Tests/KernelTestBaseTest.php \Drupal\simpletest\Tests\KernelTestBaseTest::testSetUp()
Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()

@covers ::setUp

File

core/tests/Drupal/KernelTests/KernelTestBaseTest.php, line 63
Contains \Drupal\KernelTests\KernelTestBaseTest.

Class

KernelTestBaseTest
@coversDefaultClass \Drupal\KernelTests\KernelTestBase @group PHPUnit

Namespace

Drupal\KernelTests

Code

public function testSetUp() {
  $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', array(
    'fields' => array(
      'number' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
  ));
  $this
    ->assertTrue($database
    ->schema()
    ->tableExists('foo'));

  // Ensure that the database tasks have been run during set up. Neither MySQL
  // nor SQLite make changes that are testable.
  if ($database
    ->driver() == 'pgsql') {
    $this
      ->assertEquals('on', $database
      ->query("SHOW standard_conforming_strings")
      ->fetchField());
    $this
      ->assertEquals('escape', $database
      ->query("SHOW bytea_output")
      ->fetchField());
  }
  $this
    ->assertNotNull(FileCacheFactory::getPrefix());
}