From 4e953a31c769ba9b97ed59cd45d9b4223ef3c3e7 Mon Sep 17 00:00:00 2001 From: Herb Miller Date: Fri, 22 Nov 2019 10:18:45 +0000 Subject: [PATCH] Fixes #76 - Add hex dump support for trace output wth helper function bw_trace_hexdump --- includes/bwtrace.php | 19 +++++- libs/hexdump.php | 66 +++++++++++++++++++++ oik-bwtrace.php | 2 +- phpunit.json | 124 ++++++++++++++++++++++------------------ tests/test-issue-76.php | 30 ++++++++++ 5 files changed, 184 insertions(+), 57 deletions(-) create mode 100644 libs/hexdump.php create mode 100644 tests/test-issue-76.php diff --git a/includes/bwtrace.php b/includes/bwtrace.php index d9933d2..839c6b5 100644 --- a/includes/bwtrace.php +++ b/includes/bwtrace.php @@ -1037,7 +1037,24 @@ function bw_list_trace_levels() { function bw_trace_trace_startup() { global $bw_trace; $bw_trace->trace_startup(); -} +} + +/** + * Returns a hexdump version of the string + * + * @param string $string + * @return string + */ +function bw_trace_hexdump( $string ) { + if ( !function_exists( "oik_hexdump") ) { + oik_require_lib( 'hexdump' ); + } + if ( function_exists( "oik_hexdump" ) ) { + $string = oik_hexdump( $string ); + } + return $string; + +} } diff --git a/libs/hexdump.php b/libs/hexdump.php new file mode 100644 index 0000000..238e0f5 --- /dev/null +++ b/libs/hexdump.php @@ -0,0 +1,66 @@ + null, "bobbforms" => "bobbfunc", "oik-admin" => "bobbforms" ); + $libs = array( "bobbfunc" => null, "bobbforms" => "bobbfunc", "oik-admin" => "bobbforms", 'hexdump' => null ); $versions = array( "bobbfunc" => "3.2.0", "bobbforms" => "3.2.0", "oik-admin" => "3.2.0" ); foreach ( $libs as $library => $depends ) { $lib_args['library'] = $library; diff --git a/phpunit.json b/phpunit.json index 183477d..460a0c4 100644 --- a/phpunit.json +++ b/phpunit.json @@ -1,69 +1,83 @@ - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - + + + - - + + - - - - - + + + + + - - - - + + - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/test-issue-76.php b/tests/test-issue-76.php new file mode 100644 index 0000000..2d23c6a --- /dev/null +++ b/tests/test-issue-76.php @@ -0,0 +1,30 @@ +assertEquals( $expected, $hex ); + + } + + + +} \ No newline at end of file