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

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