Added backtrace formatter test.
This commit is contained in:
1 parent
5ee99cddd4
commit
4dbcddad8d
1 file changed
+58
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rarst\Laps\Tests\Formatter;
|
||||||
|
|
||||||
|
use Brain\Monkey\Functions;
|
||||||
|
use Rarst\Laps\Formatter\Backtrace_Formatter;
|
||||||
|
use Rarst\Laps\Tests\LapsTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass Rarst\Laps\Formatter\Backtrace_Formatter
|
||||||
|
*/
|
||||||
|
class BacktraceTest extends LapsTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::__construct
|
||||||
|
*
|
||||||
|
* @return Backtrace_Formatter
|
||||||
|
*/
|
||||||
|
public function test__construct() {
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
|
return new Backtrace_Formatter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends test__construct
|
||||||
|
*/
|
||||||
|
public function testFormat( Backtrace_Formatter $formatter ) {
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
define( 'ABSPATH', '/wp' );
|
||||||
|
define( 'WP_CONTENT_DIR', '/wp-content/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg();
|
||||||
|
|
||||||
|
$backtrace = [
|
||||||
|
'template-loader.php',
|
||||||
|
'WP_Hook->do_action',
|
||||||
|
'foo',
|
||||||
|
"include('/wp/path.php')",
|
||||||
|
];
|
||||||
|
|
||||||
|
$backtrace = implode( ', ', $backtrace );
|
||||||
|
|
||||||
|
$result = $formatter->format( $backtrace );
|
||||||
|
|
||||||
|
$this->assertInternalType( 'array', $result );
|
||||||
|
$this->assertArraySubset( [ 'foo', 'path.php' ], array_values( $result ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user