function ErrorTest::providerTestGetLastCaller

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::providerTestGetLastCaller()
  2. 8.9.x core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::providerTestGetLastCaller()
  3. 10 core/tests/Drupal/Tests/Core/Utility/ErrorTest.php \Drupal\Tests\Core\Utility\ErrorTest::providerTestGetLastCaller()

Data provider for testGetLastCaller.

Return value

array An array of parameter data.

File

core/tests/Drupal/Tests/Core/Utility/ErrorTest.php, line 36

Class

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

Namespace

Drupal\Tests\Core\Utility

Code

public static function providerTestGetLastCaller() : array {
    $data = [];
    // Test with just one item. This should default to the function being
    // main().
    $single_item = [
        self::createBacktraceItem(),
    ];
    $data[] = [
        $single_item,
        self::createBacktraceItem('main()'),
    ];
    // Add a second item, without a class.
    $two_items = $single_item;
    $two_items[] = self::createBacktraceItem('test_function_two');
    $data[] = [
        $two_items,
        self::createBacktraceItem('test_function_two()'),
    ];
    // Add a second item, with a class.
    $two_items = $single_item;
    $two_items[] = self::createBacktraceItem('test_function_two', 'TestClass');
    $data[] = [
        $two_items,
        self::createBacktraceItem('TestClass->test_function_two()'),
    ];
    // Add ignored functions to backtrace. They should get removed.
    foreach ([
        'debug',
        '_drupal_error_handler',
        '_drupal_exception_handler',
    ] as $function) {
        $two_items = $single_item;
        // Push to the start of the backtrace.
        array_unshift($two_items, self::createBacktraceItem($function));
        $data[] = [
            $single_item,
            self::createBacktraceItem('main()'),
        ];
    }
    return $data;
}

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