function ErrorTest::providerTestFormatBacktrace

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::providerTestFormatBacktrace()
  2. 10 core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::providerTestFormatBacktrace()
  3. 11.x 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 82

Class

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

Namespace

Drupal\Tests\Core\Utility

Code

public function providerTestFormatBacktrace() {
    $data = [];
    // Test with no function, main should be in the backtrace.
    $data[] = [
        [
            $this->createBacktraceItem(NULL, NULL),
        ],
        "main() (Line: 10)\n",
    ];
    $base = [
        $this->createBacktraceItem(),
    ];
    $data[] = [
        $base,
        "test_function() (Line: 10)\n",
    ];
    // Add a second item.
    $second_item = $base;
    $second_item[] = $this->createBacktraceItem('test_function_2');
    $data[] = [
        $second_item,
        "test_function() (Line: 10)\ntest_function_2() (Line: 10)\n",
    ];
    // Add a second item, with a class.
    $second_item_class = $base;
    $second_item_class[] = $this->createBacktraceItem('test_function_2', 'TestClass');
    $data[] = [
        $second_item_class,
        "test_function() (Line: 10)\nTestClass->test_function_2() (Line: 10)\n",
    ];
    // Add a second item, with a class.
    $second_item_args = $base;
    $second_item_args[] = $this->createBacktraceItem('test_function_2', NULL, [
        'string',
        10,
        new \stdClass(),
    ]);
    $data[] = [
        $second_item_args,
        "test_function() (Line: 10)\ntest_function_2('string', 10, Object) (Line: 10)\n",
    ];
    return $data;
}

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