function ErrorTest::providerTestFormatBacktrace

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

Class

ErrorTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Utility%21Error.php/class/Error/11.x" title="Drupal error utility class." class="local">\Drupal\Core\Utility\Error</a> @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

public static function providerTestFormatBacktrace() : array {
    $data = [];
    // Test with no function, main should be in the backtrace.
    $data[] = [
        [
            self::createBacktraceItem(NULL, NULL),
        ],
        "main() (Line: 10)\n",
    ];
    $base = [
        self::createBacktraceItem(),
    ];
    $data[] = [
        $base,
        "test_function() (Line: 10)\n",
    ];
    // Add a second item.
    $second_item = $base;
    $second_item[] = self::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[] = self::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[] = self::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.