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

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