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

Source for file PHP_Debug_HTML_Div_test.php

Documentation is available at PHP_Debug_HTML_Div_test.php

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

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