PHP_Debug
[ class tree: PHP_Debug ] [ index: PHP_Debug ] [ all elements ]

Source for file PHP_Debug_HTML_Table_test.php

Documentation is available at PHP_Debug_HTML_Table_test.php

  1. <?php
  2.  
  3. /**
  4.  * Created on 18 apr 2006
  5.  *
  6.  * Test script for PHP_Debug 2.0.0
  7.  * 
  8.  * @package PHP_Debug
  9.  * @author  COil
  10.  * @since V2.0.0 - 6 apr 2006
  11.  * @filesource
  12.  * 
  13.  * @version    CVS: $Id: PHP_Debug_HTML_Table_test.php,v 1.2 2008/08/31 19:32:50 c0il Exp $
  14.  */
  15.  
  16. error_reporting(E_ALL)// Report all possible errors
  17. //session_start();      // Start session
  18.  
  19. $renderer 'HTML_Table';
  20.  
  21. // Options array for Debug object
  22. $options = array(
  23.     'render_type'          => 'HTML',
  24.     'render_mode'          => 'Table',
  25.     'restrict_access'      => false,
  26.     'allow_url_access'     => true,
  27.     'url_key'              => 'key',
  28.     'url_pass'             => 'nounou',
  29.     'enable_watch'         => false,
  30.     'replace_errorhandler' => true,
  31.     'lang'                 => 'FR',
  32.     'HTML_TABLE_view_source_script_name' => 'PHP_Debug_ShowSource.php',
  33.     'HTML_TABLE_css_path'        => 'css'
  34. );
  35.  
  36. $allowedip = array
  37.     '127.0.0.1'
  38. );
  39.  
  40.  
  41. require_once 'PHP/Debug.php';
  42.  
  43. echo '<?xml version="1.0" encoding="UTF-8"?>
  44. <!DOCTYPE html 
  45.      PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  46.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  47. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  48.   <head>
  49.     <title>Pear::PHP_Debug</title>
  50.     <link rel="stylesheet" type="text/css" media="screen" href="'$options['HTML_TABLE_css_path'.'/html_table.css" />
  51. ';
  52. ?>
  53.   </head>
  54. <body>
  55. <h1>PEAR::PHP_Debug</h1>
  56. <p>
  57.     <a href="http://validator.w3.org/check?uri=referer"><img
  58.         src="http://www.w3.org/Icons/valid-xhtml10"
  59.         alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
  60. </p>
  61.  
  62. <p>
  63.     <a href="PHP_Debug_HTML_Div_test.php">&raquo; HTML_DIV Renderer</a><br/>
  64.     <a href="PHP_Debug_HTML_Table_test.php">&raquo; HTML_Table Renderer</a><br/>
  65.     <a href="PHP_Debug_test.php">&raquo; Test min</a><br/>
  66.     <a href="PHP_Debug_Sources.php">&raquo; Show sources</a><br/>
  67. </p>
  68.  
  69. <?php
  70. // Tests variables  ============================================================
  71.  
  72. // One variable that will be watched by PHP_Debug
  73. $watchedVariable = 1; 
  74.  
  75. // One session variable to test the debugtype = PHP_DebuLine::TYPE_ENV (4)
  76. $_SESSION['Kikoo''One session variable defined';
  77.  
  78.  
  79. // Debug Object creation =======================================================
  80.  
  81. $Dbg = new PHP_Debug($options);
  82.  
  83.  
  84. // Test restrictAcess() function, only IP in param array will see the debug ====
  85.  
  86. //$Dbg->restrictAcess($allowedip);
  87.  
  88.  
  89.  
  90. // Test add() function =========================================================
  91.  
  92. // Standard 
  93. $Dbg->add("This is the <b>HTML_Table_Render</b>, client IP is "
  94.     $_SERVER['REMOTE_ADDR']);
  95.  
  96. // Standard, fix end and start time manually
  97. $debug_line $Dbg->add('Manual performance monitoring');
  98. $debug_line->setStartTime();
  99. for ($i = 0; $i < 20000; $i++{
  100.     $j = 0;
  101. }
  102. $debug_line->setEndTime();
  103.  
  104. // Test dump() function ========================================================
  105.  
  106. // dump a variable (integer)
  107. $foo = 555;
  108. $Dbg->dump($foo'Foo');
  109.  
  110. // dump a variable (double)
  111. $foo2 = 37.2;
  112. $Dbg->dump($foo2'Foo2');
  113.  
  114. // dump an array
  115. //$Dbg->dump($options, 'Options');
  116.  
  117. // dump an object
  118. $testObject = new PHP_DebugLine('info info info inside DebugLine object');
  119. $Dbg->dump($testObject);
  120.  
  121. // dump an object and die the script 
  122. //PHP_Debug::dumpVar($testObject, 'stooooooop', true);
  123.  
  124.  
  125. // Test setAction() ============================================================
  126.  
  127.  
  128. // Type 12 : Page action : --> Methode publique a creer
  129. $action 'view_test_action';
  130. $Dbg->setAction($action);
  131.  
  132.  
  133. // Test watch() function, watched var is 'watchedVariable' =====================
  134.  
  135. // /!\ Be carefull the tick directive does not work under windows /!\
  136. // and make apache crash. To test under unix, remove comments bellow and
  137. // corresponding brace line 163 
  138.   
  139. //declare (ticks = 1) 
  140. //{
  141.  
  142.     // Watch the variable called 'watchedVariable' 
  143.     //$Dbg->watch('watchedVariable');
  144.  
  145.     // Stress backtrace function (check line, file, function, class results) ===
  146.  
  147.     function a()
  148.     {
  149.         global $Dbg$watchedVariable;
  150.         $Dbg->addDebug('call from a() fonction');
  151.         $Dbg->stopTimer();
  152.     
  153.         $watchedVariable = 501;
  154.         
  155.         b();
  156.     }
  157.     
  158.     function b()
  159.     {
  160.         global $Dbg$watchedVariable;
  161.         $Dbg->add('call from b() fonction');
  162.     
  163.         $watchedVariable = 502;
  164.     }
  165.  
  166.     a();
  167.     
  168.     $Dbg->addDebugFirst('call after b() and a() but adding in 1st');
  169.     
  170.     $watchedVariable = 555;    
  171.     $watchedVariable 'converting from INT to STR';
  172.  
  173. //} // End of declare {ticks=n}  block
  174.  
  175.  
  176. // Test the add() function with the timer ======================================
  177.  
  178. $Dbg->add('PERF TEST : 10000 iteration');
  179.  
  180. $y = 0;
  181. for ($index = 0; $index < 10000; $index++{
  182.     $y $y $index;
  183. }
  184. $Dbg->stopTimer();
  185.  
  186.  
  187. // Test the query() function ===================================================
  188.  
  189. $Dbg->query('SELECT * FROM PHP_DEBUG_USERS');
  190.  
  191. $y = 0;
  192. for ($index = 0; $index < 10000; $index++{
  193.     $y $y $index;
  194. }
  195. $Dbg->stopTimer();
  196.  
  197.  
  198.  
  199. // Test custom error handler ===================================================
  200.  
  201. echo $notset;                      // Will raise a PHP notice
  202. fopen('not existing!''r');       // Will raise a PHP warning
  203. trigger_error('This is a custom application error !!'E_USER_ERROR);
  204.                                    // Will raise a custom user error
  205. $Dbg->error('Bad status of var x in application PHP_Debug');
  206.                                    // Will add an application error
  207.  
  208.  
  209. // Display Debug information (HTML_Table renderer) =============================
  210.  
  211. $Dbg->display();
  212.  
  213.  
  214. // Test __toString(), dumpVar() functions and structure of Debug object ========
  215.  
  216. //echo $Dbg;
  217.  
  218.  
  219. // END =========================================================================
  220. ?>
  221. </body>
  222. </html>

Documentation generated on Mon, 11 Mar 2019 15:25:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.