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:$
  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_Div_test.php?enable_w3c_validator=1">&raquo; HTML_DIV Renderer with W3C output validation</a><br/>
  65.     <a href="PHP_Debug_HTML_Table_test.php">&raquo; HTML_Table Renderer</a><br/>
  66.     <a href="PHP_Debug_test.php">&raquo; Test min</a><br/>
  67.     <a href="PHP_Debug_Sources.php">&raquo; Show sources</a><br/>
  68. </p>
  69.  
  70. <?php
  71. // Tests variables  ============================================================
  72.  
  73. // One variable that will be watched by PHP_Debug
  74. $watchedVariable = 1; 
  75.  
  76. // One session variable to test the debugtype = PHP_DebuLine::TYPE_ENV (4)
  77. $_SESSION['Kikoo''One session variable defined';
  78.  
  79.  
  80. // Debug Object creation =======================================================
  81.  
  82. $Dbg = new PHP_Debug($options);
  83.  
  84.  
  85. // Test restrictAcess() function, only IP in param array will see the debug ====
  86.  
  87. //$Dbg->restrictAcess($allowedip);
  88.  
  89.  
  90.  
  91. // Test add() function =========================================================
  92.  
  93. // Standard 
  94. $Dbg->add("This is the <b>HTML_Table_Render</b>, client IP is "
  95.     $_SERVER['REMOTE_ADDR']);
  96.  
  97. // Standard, fix end and start time manually
  98. $debug_line $Dbg->add('Manual performance monitoring');
  99. $debug_line->setStartTime();
  100. for ($i = 0; $i < 20000; $i++{
  101.     $j = 0;
  102. }
  103. $debug_line->setEndTime();
  104.  
  105. // Test dump() function ========================================================
  106.  
  107. // dump a variable (integer)
  108. $foo = 555;
  109. $Dbg->dump($foo'Foo');
  110.  
  111. // dump a variable (double)
  112. $foo2 = 37.2;
  113. $Dbg->dump($foo2'Foo2');
  114.  
  115. // dump an array
  116. //$Dbg->dump($options, 'Options');
  117.  
  118. // dump an object
  119. $testObject = new PHP_DebugLine('info info info inside DebugLine object');
  120. $Dbg->dump($testObject);
  121.  
  122. // dump an object and die the script 
  123. //PHP_Debug::dumpVar($testObject, 'stooooooop', true);
  124.  
  125.  
  126. // Test setAction() ============================================================
  127.  
  128.  
  129. // Type 12 : Page action : --> Methode publique a creer
  130. $action 'view_test_action';
  131. $Dbg->setAction($action);
  132.  
  133.  
  134. // Test watch() function, watched var is 'watchedVariable' =====================
  135.  
  136. // /!\ Be carefull the tick directive does not work under windows /!\
  137. // and make apache crash. To test under unix, remove comments bellow and
  138. // corresponding brace line 163 
  139.   
  140. //declare (ticks = 1) 
  141. //{
  142.  
  143.     // Watch the variable called 'watchedVariable' 
  144.     //$Dbg->watch('watchedVariable');
  145.  
  146.     // Stress backtrace function (check line, file, function, class results) ===
  147.  
  148.     function a()
  149.     {
  150.         global $Dbg$watchedVariable;
  151.         $Dbg->addDebug('call from a() fonction');
  152.         $Dbg->stopTimer();
  153.     
  154.         $watchedVariable = 501;
  155.         
  156.         b();
  157.     }
  158.     
  159.     function b()
  160.     {
  161.         global $Dbg$watchedVariable;
  162.         $Dbg->add('call from b() fonction');
  163.     
  164.         $watchedVariable = 502;
  165.     }
  166.  
  167.     a();
  168.     
  169.     $Dbg->addDebugFirst('call after b() and a() but adding in 1st');
  170.     
  171.     $watchedVariable = 555;    
  172.     $watchedVariable 'converting from INT to STR';
  173.  
  174. //} // End of declare {ticks=n}  block
  175.  
  176.  
  177. // Test the add() function with the timer ======================================
  178.  
  179. $Dbg->add('PERF TEST : 10000 iteration');
  180.  
  181. $y = 0;
  182. for ($index = 0; $index < 10000; $index++{
  183.     $y $y $index;
  184. }
  185. $Dbg->stopTimer();
  186.  
  187.  
  188. // Test the query() function ===================================================
  189.  
  190. $Dbg->query('SELECT * FROM PHP_DEBUG_USERS');
  191.  
  192. $y = 0;
  193. for ($index = 0; $index < 10000; $index++{
  194.     $y $y $index;
  195. }
  196. $Dbg->stopTimer();
  197.  
  198.  
  199.  
  200. // Test custom error handler ===================================================
  201.  
  202. echo $notset;                      // Will raise a PHP notice
  203. fopen('not existing!''r');       // Will raise a PHP warning
  204. trigger_error('This is a custom application error !!'E_USER_ERROR);
  205.                                    // Will raise a custom user error
  206. $Dbg->error('Bad status of var x in application PHP_Debug');
  207.                                    // Will add an application error
  208.  
  209.  
  210. // Display Debug information (HTML_Table renderer) =============================
  211.  
  212. $Dbg->display();
  213.  
  214.  
  215. // Test __toString(), dumpVar() functions and structure of Debug object ========
  216.  
  217. //echo $Dbg;
  218.  
  219.  
  220. // END =========================================================================
  221. ?>
  222. </body>
  223. </html>

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