function UnitTestCaseTest::testVarDumpSeparateProcess

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/UnitTestCaseTest.php \Drupal\Tests\UnitTestCaseTest::testVarDumpSeparateProcess()
  2. 10 core/tests/Drupal/Tests/UnitTestCaseTest.php \Drupal\Tests\UnitTestCaseTest::testVarDumpSeparateProcess()

Tests the dump() function in a test run in a separate process.

@runInSeparateProcess

File

core/tests/Drupal/Tests/UnitTestCaseTest.php, line 39

Class

UnitTestCaseTest
Tests for the UnitTestCase class.

Namespace

Drupal\Tests

Code

public function testVarDumpSeparateProcess() : void {
  // Dump some variables.
  $object = (object) [
    'Denebola' => 'Aspidiske',
  ];
  dump($object);
  dump('Schedar');
  $dumpString = json_encode(DebugDump::getDumps());
  $this->assertStringContainsString('Denebola', $dumpString);
  $this->assertStringContainsString('Aspidiske', $dumpString);
  $this->assertStringContainsString('Schedar', $dumpString);
  // We should also find the dump of the previous test.
  $this->assertStringContainsString('Aldebaran', $dumpString);
  $this->assertStringContainsString('Betelgeuse', $dumpString);
  $this->assertStringContainsString('Alpheratz', $dumpString);
}

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