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

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