ZF-8222: format class name for class checks
[zend.git] / tests / Zend / DebugTest.php
blobbff7bacfae7324c1d7491cd435450946a94b1a2b
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Debug
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id $
23 /**
24 * Test helper
26 require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php';
28 /**
29 * Zend_Debug
31 require_once 'Zend/Debug.php';
33 /**
34 * @category Zend
35 * @package Zend_Debug
36 * @subpackage UnitTests
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
38 * @license http://framework.zend.com/license/new-bsd New BSD License
39 * @group Zend_Debug
41 class Zend_DebugTest extends PHPUnit_Framework_TestCase
44 public function testDebugDefaultSapi()
46 $sapi = php_sapi_name();
47 Zend_Debug::setSapi(null);
48 $data = 'string';
49 $result = Zend_Debug::Dump($data, null, false);
50 $this->assertEquals($sapi, Zend_Debug::getSapi());
53 public function testDebugDump()
55 Zend_Debug::setSapi('cli');
56 $data = 'string';
57 $result = Zend_Debug::Dump($data, null, false);
58 $result = str_replace(array(PHP_EOL, "\n"), '_', $result);
59 $expected = "__string(6) \"string\"__";
60 $this->assertEquals($expected, $result);
63 public function testDebugCgi()
65 Zend_Debug::setSapi('cgi');
66 $data = 'string';
67 $result = Zend_Debug::Dump($data, null, false);
69 // Has to check for two strings, because xdebug internally handles CLI vs Web
70 $this->assertContains($result,
71 array(
72 "<pre>string(6) \"string\"\n</pre>",
73 "<pre>string(6) &quot;string&quot;\n</pre>",
78 public function testDebugDumpEcho()
80 Zend_Debug::setSapi('cli');
81 $data = 'string';
83 ob_start();
84 $result1 = Zend_Debug::Dump($data, null, true);
85 $result2 = ob_get_contents();
86 ob_end_clean();
88 $this->assertContains('string(6) "string"', $result1);
89 $this->assertEquals($result1, $result2);
92 public function testDebugDumpLabel()
94 Zend_Debug::setSapi('cli');
95 $data = 'string';
96 $label = 'LABEL';
97 $result = Zend_Debug::Dump($data, $label, false);
98 $result = str_replace(array(PHP_EOL, "\n"), '_', $result);
99 $expected = "_{$label} _string(6) \"string\"__";
100 $this->assertEquals($expected, $result);
104 * @group ZF-4136
105 * @group ZF-1663
107 public function testXdebugEnabledAndNonCliSapiDoesNotEscapeSpecialChars()
109 if(!extension_loaded('xdebug')) {
110 $this->markTestSkipped("This test only works in combination with xdebug.");
113 Zend_Debug::setSapi('apache');
114 $a = array("a" => "b");
116 $result = Zend_Debug::dump($a, "LABEL", false);
117 $this->assertContains("<pre>", $result);
118 $this->assertContains("</pre>", $result);