/**
* Retrieves the current calling line in the class under test.
*
* @return array
* An associative array with keys 'file', 'line' and 'function'.
*/
protected function getTestMethodCaller() { $backtrace =
debug_backtrace();
// Find the test class that has the test method.
while ($caller = Error::
getLastCaller($backtrace)) { // If we match PHPUnit's TestCase::runTest, then the previously processed
// caller entry is where our test method sits.
if (isset($last_caller) &&
isset($caller['function'
]) &&
$caller['function'
] === 'PHPUnit\Framework\TestCase->runTest()'
) { // Return the last caller since that has to be the test class.
$caller =
$last_caller;
break;
} // If the test method is implemented by a test class's parent then the
// class name of $this will not be part of the backtrace.
// In that case we process the backtrace until the caller is not a