2010-11-24 07:23:50 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2010-11-24 07:23:50 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class BacktraceTest extends SapphireTest {
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testFullFuncNameWithArgsAndCustomCharLimit() {
|
2010-11-24 07:23:50 +01:00
|
|
|
$func = array(
|
|
|
|
'class' => 'MyClass',
|
|
|
|
'type' => '->',
|
|
|
|
'file' => 'MyFile.php',
|
|
|
|
'line' => 99,
|
|
|
|
'function' => 'myFunction',
|
|
|
|
'args' => array(
|
|
|
|
'number' => 1,
|
|
|
|
'mylongstring' => 'more than 20 characters 1234567890',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
'MyClass->myFunction(1,more than 20 charact...)',
|
|
|
|
SS_Backtrace::full_func_name($func, true, 20)
|
|
|
|
);
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testIgnoredFunctionArgs() {
|
2011-05-26 12:04:01 +02:00
|
|
|
$bt = array(
|
|
|
|
array(
|
|
|
|
'type' => '->',
|
|
|
|
'file' => 'MyFile.php',
|
|
|
|
'line' => 99,
|
|
|
|
'function' => 'myIgnoredGlobalFunction',
|
|
|
|
'args' => array('password' => 'secred',)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'class' => 'MyClass',
|
|
|
|
'type' => '->',
|
|
|
|
'file' => 'MyFile.php',
|
|
|
|
'line' => 99,
|
|
|
|
'function' => 'myIgnoredClassFunction',
|
|
|
|
'args' => array('password' => 'secred',)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'class' => 'MyClass',
|
|
|
|
'type' => '->',
|
|
|
|
'file' => 'MyFile.php',
|
|
|
|
'line' => 99,
|
|
|
|
'function' => 'myFunction',
|
|
|
|
'args' => array('myarg' => 'myval')
|
|
|
|
)
|
|
|
|
);
|
2013-03-21 19:48:54 +01:00
|
|
|
$orig = Config::inst()->get('SS_Backtrace', 'ignore_function_args');
|
2014-08-15 08:53:05 +02:00
|
|
|
Config::inst()->update('SS_Backtrace', 'ignore_function_args',
|
2013-03-21 19:48:54 +01:00
|
|
|
array(
|
|
|
|
array('MyClass', 'myIgnoredClassFunction'),
|
|
|
|
'myIgnoredGlobalFunction'
|
|
|
|
)
|
|
|
|
);
|
2011-05-26 12:04:01 +02:00
|
|
|
|
|
|
|
$filtered = SS_Backtrace::filter_backtrace($bt);
|
|
|
|
|
|
|
|
$this->assertEquals('<filtered>', $filtered[0]['args']['password'], 'Filters global functions');
|
|
|
|
$this->assertEquals('<filtered>', $filtered[1]['args']['password'], 'Filters class functions');
|
|
|
|
$this->assertEquals('myval', $filtered[2]['args']['myarg'], 'Doesnt filter other functions');
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2013-03-21 19:48:54 +01:00
|
|
|
Config::inst()->remove('SS_Backtrace', 'ignore_function_args');
|
|
|
|
Config::inst()->update('SS_Backtrace', 'ignore_function_args', $orig);
|
2011-05-26 12:04:01 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|