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

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