| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
|
|
|
11 |
require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
|
|
|
12 |
|
|
|
13 |
$t = new lime_test(5);
|
|
|
14 |
|
|
|
15 |
class sfWebDebugPanelPropelTest extends sfWebDebugPanelPropel
|
|
|
16 |
{
|
|
|
17 |
protected function getPropelConfiguration()
|
|
|
18 |
{
|
|
|
19 |
$config = new PropelConfiguration(array());
|
|
|
20 |
$config->setParameter('debugpdo.logging.details.slow.enabled', true);
|
|
|
21 |
$config->setParameter('debugpdo.logging.details.slow.threshold', 1);
|
|
|
22 |
return $config;
|
|
|
23 |
}
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
class sfWebDebugPanelPropelTestDifferentGlue extends sfWebDebugPanelPropel
|
|
|
27 |
{
|
|
|
28 |
protected function getPropelConfiguration()
|
|
|
29 |
{
|
|
|
30 |
$config = new PropelConfiguration(array());
|
|
|
31 |
$config->setParameter('debugpdo.logging.outerglue', 'xx');
|
|
|
32 |
$config->setParameter('debugpdo.logging.innerglue', '/ ');
|
|
|
33 |
$config->setParameter('debugpdo.logging.details.slow.enabled', true);
|
|
|
34 |
$config->setParameter('debugpdo.logging.details.slow.threshold', 5);
|
|
|
35 |
return $config;
|
|
|
36 |
}
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
// ->getPanelContent()
|
|
|
40 |
$t->diag('->getPanelContent()');
|
|
|
41 |
|
|
|
42 |
$dispatcher = new sfEventDispatcher();
|
|
|
43 |
$logger = new sfVarLogger($dispatcher);
|
|
|
44 |
$logger->log('{sfPropelLogger} SELECT * FROM foo WHERE bar<1');
|
|
|
45 |
$logger->log('{sfPropelLogger} time: 3.42 sec | mem: 2.8 MB | SELECT * FROM foo WHERE aText like \' | foo\'');
|
|
|
46 |
$panel = new sfWebDebugPanelPropelTest(new sfWebDebug($dispatcher, $logger));
|
|
|
47 |
$content = $panel->getPanelContent();
|
|
|
48 |
$t->like($content, '/bar<1/', '->getPanelContent() returns escaped queries');
|
|
|
49 |
$t->like($content, '/aText like ' | foo'/', '->getPanelContent() works with glue string in SQL');
|
|
|
50 |
$t->like($content, '/sfWebDebugWarning/', '->getPanelContent() contains a slow query warning');
|
|
|
51 |
|
|
|
52 |
$logger = new sfVarLogger($dispatcher);
|
|
|
53 |
$logger->log('{sfPropelLogger} time/ 3.42 secxxmem/ 2.8 MBxxSELECT * FROM foo WHERE bar == 42');
|
|
|
54 |
$panel = new sfWebDebugPanelPropelTestDifferentGlue(new sfWebDebug($dispatcher, $logger));
|
|
|
55 |
$content = $panel->getPanelContent();
|
|
|
56 |
$t->like($content, '/time\/ 3.42 sec, mem\/ 2.8 MB/', '->getPanelContent() works with strange glue strings');
|
|
|
57 |
$t->unlike($content, '/sfWebDebugWarning/', '->getPanelContent() should not contain a slow warning');
|