You are here

public function ErrorTest::providerTestFormatBacktrace in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::providerTestFormatBacktrace()

Data provider for testFormatBacktrace.

Return value

array

File

core/tests/Drupal/Tests/Core/Utility/ErrorTest.php, line 88
Contains \Drupal\Tests\Core\Utility\ErrorTest.

Class

ErrorTest
@coversDefaultClass \Drupal\Core\Utility\Error @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

public function providerTestFormatBacktrace() {
  $data = array();

  // Test with no function, main should be in the backtrace.
  $data[] = array(
    array(
      $this
        ->createBacktraceItem(NULL, NULL),
    ),
    "main()\n",
  );
  $base = array(
    $this
      ->createBacktraceItem(),
  );
  $data[] = array(
    $base,
    "test_function()\n",
  );

  // Add a second item.
  $second_item = $base;
  $second_item[] = $this
    ->createBacktraceItem('test_function_2');
  $data[] = array(
    $second_item,
    "test_function()\ntest_function_2()\n",
  );

  // Add a second item, with a class.
  $second_item_class = $base;
  $second_item_class[] = $this
    ->createBacktraceItem('test_function_2', 'TestClass');
  $data[] = array(
    $second_item_class,
    "test_function()\nTestClass->test_function_2()\n",
  );

  // Add a second item, with a class.
  $second_item_args = $base;
  $second_item_args[] = $this
    ->createBacktraceItem('test_function_2', NULL, array(
    'string',
    10,
    new \stdClass(),
  ));
  $data[] = array(
    $second_item_args,
    "test_function()\ntest_function_2('string', 10, Object)\n",
  );
  return $data;
}