PageRenderTime 60ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/tests/cases/basics.test.php

https://github.com/hardsshah/bookmarks
PHP | 676 lines | 412 code | 88 blank | 176 comment | 2 complexity | 5c24e43ba8a8aee6587e5f233dc57f5d MD5 | raw file
  1. <?php
  2. /* SVN FILE: $Id$ */
  3. /**
  4. * BasicsTest file
  5. *
  6. * Long description for file
  7. *
  8. * PHP versions 4 and 5
  9. *
  10. * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
  11. * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  12. *
  13. * Licensed under The Open Group Test Suite License
  14. * Redistributions of files must retain the above copyright notice.
  15. *
  16. * @filesource
  17. * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  18. * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
  19. * @package cake
  20. * @subpackage cake.tests.cases
  21. * @since CakePHP(tm) v 1.2.0.4206
  22. * @version $Revision$
  23. * @modifiedby $LastChangedBy$
  24. * @lastmodified $Date$
  25. * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
  26. */
  27. require_once CAKE . 'basics.php';
  28. App::import('Core', 'Folder');
  29. /**
  30. * BasicsTest class
  31. *
  32. * @package cake
  33. * @subpackage cake.tests.cases
  34. */
  35. class BasicsTest extends CakeTestCase {
  36. /**
  37. * setUp method
  38. *
  39. * @access public
  40. * @return void
  41. */
  42. function setUp() {
  43. Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
  44. }
  45. /**
  46. * testHttpBase method
  47. *
  48. * @return void
  49. * @access public
  50. */
  51. function testEnv() {
  52. $this->skipIf(!function_exists('ini_get') || ini_get('safe_mode') === '1', '%s safe mode is on');
  53. $__SERVER = $_SERVER;
  54. $__ENV = $_ENV;
  55. $_SERVER['HTTP_HOST'] = 'localhost';
  56. $this->assertEqual(env('HTTP_BASE'), '');
  57. $_SERVER['HTTP_HOST'] = 'example.com';
  58. $this->assertEqual(env('HTTP_BASE'), '.example.com');
  59. $_SERVER['HTTP_HOST'] = 'www.example.com';
  60. $this->assertEqual(env('HTTP_BASE'), '.example.com');
  61. $_SERVER['HTTP_HOST'] = 'subdomain.example.com';
  62. $this->assertEqual(env('HTTP_BASE'), '.example.com');
  63. $_SERVER['HTTP_HOST'] = 'double.subdomain.example.com';
  64. $this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com');
  65. $_SERVER = $_ENV = array();
  66. $_SERVER['SCRIPT_NAME'] = '/a/test/test.php';
  67. $this->assertEqual(env('SCRIPT_NAME'), '/a/test/test.php');
  68. $_SERVER = $_ENV = array();
  69. $_ENV['CGI_MODE'] = 'BINARY';
  70. $_ENV['SCRIPT_URL'] = '/a/test/test.php';
  71. $this->assertEqual(env('SCRIPT_NAME'), '/a/test/test.php');
  72. $_SERVER = $_ENV = array();
  73. $_SERVER['HTTPS'] = 'on';
  74. $this->assertTrue(env('HTTPS'));
  75. $_SERVER['HTTPS'] = 'off';
  76. $this->assertFalse(env('HTTPS'));
  77. $_SERVER = array();
  78. $_ENV['SCRIPT_URI'] = 'https://domain.test/a/test.php';
  79. $this->assertTrue(env('HTTPS'));
  80. $_ENV['SCRIPT_URI'] = 'http://domain.test/a/test.php';
  81. $this->assertFalse(env('HTTPS'));
  82. $_SERVER = $_ENV = array();
  83. $this->assertFalse(env('TEST_ME'));
  84. $_ENV['TEST_ME'] = 'a';
  85. $this->assertEqual(env('TEST_ME'), 'a');
  86. $_SERVER['TEST_ME'] = 'b';
  87. $this->assertEqual(env('TEST_ME'), 'b');
  88. unset($_ENV['TEST_ME']);
  89. $this->assertEqual(env('TEST_ME'), 'b');
  90. $_SERVER = $__SERVER;
  91. $_ENV = $__ENV;
  92. }
  93. /**
  94. * test uses()
  95. *
  96. * @access public
  97. * @return void
  98. */
  99. function testUses() {
  100. $this->skipIf(class_exists('Security') || class_exists('Sanitize'), 'Security and/or Sanitize class already loaded');
  101. $this->assertFalse(class_exists('Security'));
  102. $this->assertFalse(class_exists('Sanitize'));
  103. uses('Security', 'Sanitize');
  104. $this->assertTrue(class_exists('Security'));
  105. $this->assertTrue(class_exists('Sanitize'));
  106. }
  107. /**
  108. * Test h()
  109. *
  110. * @access public
  111. * @return void
  112. */
  113. function testH() {
  114. $string = '<foo>';
  115. $result = h($string);
  116. $this->assertEqual('&lt;foo&gt;', $result);
  117. $in = array('this & that', '<p>Which one</p>');
  118. $result = h($in);
  119. $expected = array('this &amp; that', '&lt;p&gt;Which one&lt;/p&gt;');
  120. $this->assertEqual($expected, $result);
  121. }
  122. /**
  123. * Test a()
  124. *
  125. * @access public
  126. * @return void
  127. */
  128. function testA() {
  129. $result = a('this', 'that', 'bar');
  130. $this->assertEqual(array('this', 'that', 'bar'), $result);
  131. }
  132. /**
  133. * Test aa()
  134. *
  135. * @access public
  136. * @return void
  137. */
  138. function testAa() {
  139. $result = aa('a', 'b', 'c', 'd');
  140. $expected = array('a' => 'b', 'c' => 'd');
  141. $this->assertEqual($expected, $result);
  142. $result = aa('a', 'b', 'c', 'd', 'e');
  143. $expected = array('a' => 'b', 'c' => 'd', 'e' => null);
  144. $this->assertEqual($result, $expected);
  145. }
  146. /**
  147. * Test am()
  148. *
  149. * @access public
  150. * @return void
  151. */
  152. function testAm() {
  153. $result = am(array('one', 'two'), 2, 3, 4);
  154. $expected = array('one', 'two', 2, 3, 4);
  155. $this->assertEqual($result, $expected);
  156. $result = am(array('one' => array(2, 3), 'two' => array('foo')), array('one' => array(4, 5)));
  157. $expected = array('one' => array(4, 5),'two' => array('foo'));
  158. $this->assertEqual($result, $expected);
  159. }
  160. /**
  161. * test cache()
  162. *
  163. * @access public
  164. * @return void
  165. */
  166. function testCache() {
  167. $_cacheDisable = Configure::read('Cache.disable');
  168. Configure::write('Cache.disable', true);
  169. $result = cache('basics_test', 'simple cache write');
  170. $this->assertNull($result);
  171. $result = cache('basics_test');
  172. $this->assertNull($result);
  173. Configure::write('Cache.disable', false);
  174. $result = cache('basics_test', 'simple cache write');
  175. $this->assertTrue($result);
  176. $this->assertTrue(file_exists(CACHE . 'basics_test'));
  177. $result = cache('basics_test');
  178. $this->assertEqual($result, 'simple cache write');
  179. @unlink(CACHE . 'basics_test');
  180. cache('basics_test', 'expired', '+1 second');
  181. sleep(2);
  182. $result = cache('basics_test', null, '+1 second');
  183. $this->assertNull($result);
  184. Configure::write('Cache.disable', $_cacheDisable);
  185. }
  186. /**
  187. * test clearCache()
  188. *
  189. * @access public
  190. * @return void
  191. */
  192. function testClearCache() {
  193. cache('views' . DS . 'basics_test.cache', 'simple cache write');
  194. $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test.cache'));
  195. cache('views' . DS . 'basics_test_2.cache', 'simple cache write 2');
  196. $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test_2.cache'));
  197. cache('views' . DS . 'basics_test_3.cache', 'simple cache write 3');
  198. $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test_3.cache'));
  199. $result = clearCache(array('basics_test', 'basics_test_2'), 'views', '.cache');
  200. $this->assertTrue($result);
  201. $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test.cache'));
  202. $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test.cache'));
  203. $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test_3.cache'));
  204. $result = clearCache(null, 'views', '.cache');
  205. $this->assertTrue($result);
  206. $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test_3.cache'));
  207. // Different path from views and with prefix
  208. cache('models' . DS . 'basics_test.cache', 'simple cache write');
  209. $this->assertTrue(file_exists(CACHE . 'models' . DS . 'basics_test.cache'));
  210. cache('models' . DS . 'basics_test_2.cache', 'simple cache write 2');
  211. $this->assertTrue(file_exists(CACHE . 'models' . DS . 'basics_test_2.cache'));
  212. cache('models' . DS . 'basics_test_3.cache', 'simple cache write 3');
  213. $this->assertTrue(file_exists(CACHE . 'models' . DS . 'basics_test_3.cache'));
  214. $result = clearCache('basics', 'models', '.cache');
  215. $this->assertTrue($result);
  216. $this->assertFalse(file_exists(CACHE . 'models' . DS . 'basics_test.cache'));
  217. $this->assertFalse(file_exists(CACHE . 'models' . DS . 'basics_test_2.cache'));
  218. $this->assertFalse(file_exists(CACHE . 'models' . DS . 'basics_test_3.cache'));
  219. }
  220. /**
  221. * test __()
  222. *
  223. * @access public
  224. * @return void
  225. */
  226. function test__() {
  227. Configure::write('Config.language', 'rule_1_po');
  228. $result = __('Plural Rule 1', true);
  229. $expected = 'Plural Rule 1 (translated)';
  230. $this->assertEqual($result, $expected);
  231. $result = __('Plural Rule 1 (from core)', true);
  232. $expected = 'Plural Rule 1 (from core translated)';
  233. $this->assertEqual($result, $expected);
  234. ob_start();
  235. __('Plural Rule 1 (from core)');
  236. $result = ob_get_clean();
  237. $expected = 'Plural Rule 1 (from core translated)';
  238. $this->assertEqual($result, $expected);
  239. }
  240. /**
  241. * test __n()
  242. *
  243. * @access public
  244. * @return void
  245. */
  246. function test__n() {
  247. Configure::write('Config.language', 'rule_1_po');
  248. $result = __n('%d = 1', '%d = 0 or > 1', 0, true);
  249. $expected = '%d = 0 or > 1 (translated)';
  250. $this->assertEqual($result, $expected);
  251. $result = __n('%d = 1', '%d = 0 or > 1', 1, true);
  252. $expected = '%d = 1 (translated)';
  253. $this->assertEqual($result, $expected);
  254. $result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2, true);
  255. $expected = '%d = 0 or > 1 (from core translated)';
  256. $this->assertEqual($result, $expected);
  257. ob_start();
  258. __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2);
  259. $result = ob_get_clean();
  260. $expected = '%d = 0 or > 1 (from core translated)';
  261. $this->assertEqual($result, $expected);
  262. }
  263. /**
  264. * test __d()
  265. *
  266. * @access public
  267. * @return void
  268. */
  269. function test__d() {
  270. Configure::write('Config.language', 'rule_1_po');
  271. $result = __d('default', 'Plural Rule 1', true);
  272. $expected = 'Plural Rule 1 (translated)';
  273. $this->assertEqual($result, $expected);
  274. $result = __d('core', 'Plural Rule 1', true);
  275. $expected = 'Plural Rule 1';
  276. $this->assertEqual($result, $expected);
  277. $result = __d('core', 'Plural Rule 1 (from core)', true);
  278. $expected = 'Plural Rule 1 (from core translated)';
  279. $this->assertEqual($result, $expected);
  280. ob_start();
  281. __d('core', 'Plural Rule 1 (from core)');
  282. $result = ob_get_clean();
  283. $expected = 'Plural Rule 1 (from core translated)';
  284. $this->assertEqual($result, $expected);
  285. }
  286. /**
  287. * test __dn()
  288. *
  289. * @access public
  290. * @return void
  291. */
  292. function test__dn() {
  293. Configure::write('Config.language', 'rule_1_po');
  294. $result = __dn('default', '%d = 1', '%d = 0 or > 1', 0, true);
  295. $expected = '%d = 0 or > 1 (translated)';
  296. $this->assertEqual($result, $expected);
  297. $result = __dn('core', '%d = 1', '%d = 0 or > 1', 0, true);
  298. $expected = '%d = 0 or > 1';
  299. $this->assertEqual($result, $expected);
  300. $result = __dn('core', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 0, true);
  301. $expected = '%d = 0 or > 1 (from core translated)';
  302. $this->assertEqual($result, $expected);
  303. $result = __dn('default', '%d = 1', '%d = 0 or > 1', 1, true);
  304. $expected = '%d = 1 (translated)';
  305. $this->assertEqual($result, $expected);
  306. ob_start();
  307. __dn('core', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2);
  308. $result = ob_get_clean();
  309. $expected = '%d = 0 or > 1 (from core translated)';
  310. $this->assertEqual($result, $expected);
  311. }
  312. /**
  313. * test __c()
  314. *
  315. * @access public
  316. * @return void
  317. */
  318. function test__c() {
  319. Configure::write('Config.language', 'rule_1_po');
  320. $result = __c('Plural Rule 1', 5, true);
  321. $expected = 'Plural Rule 1 (translated)';
  322. $this->assertEqual($result, $expected);
  323. $result = __c('Plural Rule 1 (from core)', 5, true);
  324. $expected = 'Plural Rule 1 (from core translated)';
  325. $this->assertEqual($result, $expected);
  326. ob_start();
  327. __c('Plural Rule 1 (from core)', 5);
  328. $result = ob_get_clean();
  329. $expected = 'Plural Rule 1 (from core translated)';
  330. $this->assertEqual($result, $expected);
  331. }
  332. /**
  333. * test __dc()
  334. *
  335. * @access public
  336. * @return void
  337. */
  338. function test__dc() {
  339. Configure::write('Config.language', 'rule_1_po');
  340. $result = __dc('default', 'Plural Rule 1', 5, true);
  341. $expected = 'Plural Rule 1 (translated)';
  342. $this->assertEqual($result, $expected);
  343. $result = __dc('default', 'Plural Rule 1 (from core)', 5, true);
  344. $expected = 'Plural Rule 1 (from core translated)';
  345. $this->assertEqual($result, $expected);
  346. $result = __dc('core', 'Plural Rule 1', 5, true);
  347. $expected = 'Plural Rule 1';
  348. $this->assertEqual($result, $expected);
  349. $result = __dc('core', 'Plural Rule 1 (from core)', 5, true);
  350. $expected = 'Plural Rule 1 (from core translated)';
  351. $this->assertEqual($result, $expected);
  352. ob_start();
  353. __dc('default', 'Plural Rule 1 (from core)', 5);
  354. $result = ob_get_clean();
  355. $expected = 'Plural Rule 1 (from core translated)';
  356. $this->assertEqual($result, $expected);
  357. }
  358. /**
  359. * test __dcn()
  360. *
  361. * @access public
  362. * @return void
  363. */
  364. function test__dcn() {
  365. Configure::write('Config.language', 'rule_1_po');
  366. $result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 5, true);
  367. $expected = '%d = 0 or > 1 (translated)';
  368. $this->assertEqual($result, $expected);
  369. $result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 5, true);
  370. $expected = '%d = 1 (from core translated)';
  371. $this->assertEqual($result, $expected);
  372. $result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 5, true);
  373. $expected = '%d = 0 or > 1';
  374. $this->assertEqual($result, $expected);
  375. ob_start();
  376. __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 5);
  377. $result = ob_get_clean();
  378. $expected = '%d = 1 (from core translated)';
  379. $this->assertEqual($result, $expected);
  380. }
  381. /**
  382. * test LogError()
  383. *
  384. * @access public
  385. * @return void
  386. */
  387. function testLogError() {
  388. @unlink(LOGS . 'error.log');
  389. LogError('Testing LogError() basic function');
  390. LogError("Testing with\nmulti-line\nstring");
  391. $result = file_get_contents(LOGS . 'error.log');
  392. $this->assertPattern('/Error: Testing LogError\(\) basic function/', $result);
  393. $this->assertNoPattern("/Error: Testing with\nmulti-line\nstring/", $result);
  394. $this->assertPattern('/Error: Testing with multi-line string/', $result);
  395. }
  396. /**
  397. * test fileExistsInPath()
  398. *
  399. * @access public
  400. * @return void
  401. */
  402. function testFileExistsInPath() {
  403. $this->skipUnless(function_exists('ini_set'), '%s ini_set function not available');
  404. $_includePath = ini_get('include_path');
  405. $path = TMP . 'basics_test';
  406. $folder1 = $path . DS . 'folder1';
  407. $folder2 = $path . DS . 'folder2';
  408. $file1 = $path . DS . 'file1.php';
  409. $file2 = $folder1 . DS . 'file2.php';
  410. $file3 = $folder1 . DS . 'file3.php';
  411. $file4 = $folder2 . DS . 'file4.php';
  412. new Folder($path, true);
  413. new Folder($folder1, true);
  414. new Folder($folder2, true);
  415. touch($file1);
  416. touch($file2);
  417. touch($file3);
  418. touch($file4);
  419. ini_set('include_path', $path . PATH_SEPARATOR . $folder1);
  420. $this->assertEqual(fileExistsInPath('file1.php'), $file1);
  421. $this->assertEqual(fileExistsInPath('file2.php'), $file2);
  422. $this->assertEqual(fileExistsInPath('folder1' . DS . 'file2.php'), $file2);
  423. $this->assertEqual(fileExistsInPath($file2), $file2);
  424. $this->assertEqual(fileExistsInPath('file3.php'), $file3);
  425. $this->assertEqual(fileExistsInPath($file4), $file4);
  426. $this->assertFalse(fileExistsInPath('file1'));
  427. $this->assertFalse(fileExistsInPath('file4.php'));
  428. $Folder = new Folder($path);
  429. $Folder->delete();
  430. ini_set('include_path', $_includePath);
  431. }
  432. /**
  433. * test convertSlash()
  434. *
  435. * @access public
  436. * @return void
  437. */
  438. function testConvertSlash() {
  439. $result = convertSlash('\path\to\location\\');
  440. $expected = '\path\to\location\\';
  441. $this->assertEqual($result, $expected);
  442. $result = convertSlash('/path/to/location/');
  443. $expected = 'path_to_location';
  444. $this->assertEqual($result, $expected);
  445. }
  446. /**
  447. * test debug()
  448. *
  449. * @access public
  450. * @return void
  451. */
  452. function testDebug() {
  453. ob_start();
  454. debug('this-is-a-test');
  455. $result = ob_get_clean();
  456. $pattern = '/.*\>(cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
  457. $pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
  458. $pattern .= '.*line.*' . (__LINE__ - 4) . '.*this-is-a-test.*/s';
  459. $this->assertPattern($pattern, $result);
  460. ob_start();
  461. debug('<div>this-is-a-test</div>', true);
  462. $result = ob_get_clean();
  463. $pattern = '/.*\>(cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
  464. $pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
  465. $pattern .= '.*line.*' . (__LINE__ - 4) . '.*&lt;div&gt;this-is-a-test&lt;\/div&gt;.*/s';
  466. $this->assertPattern($pattern, $result);
  467. }
  468. /**
  469. * test pr()
  470. *
  471. * @access public
  472. * @return void
  473. */
  474. function testPr() {
  475. ob_start();
  476. pr('this is a test');
  477. $result = ob_get_clean();
  478. $expected = "<pre>this is a test</pre>";
  479. $this->assertEqual($result, $expected);
  480. ob_start();
  481. pr(array('this' => 'is', 'a' => 'test'));
  482. $result = ob_get_clean();
  483. $expected = "<pre>Array\n(\n [this] => is\n [a] => test\n)\n</pre>";
  484. $this->assertEqual($result, $expected);
  485. }
  486. /**
  487. * test params()
  488. *
  489. * @access public
  490. * @return void
  491. */
  492. function testParams() {
  493. $this->assertNull(params('weekend'));
  494. $this->assertNull(params(array()));
  495. $this->assertEqual(params(array('weekend')), array('weekend'));
  496. $nested = array(array('weekend'));
  497. $this->assertEqual(params($nested), array('weekend'));
  498. $multiple = array(array('weekend'), 'jean-luc', 'godard');
  499. $this->assertEqual(params($multiple), $multiple);
  500. }
  501. /**
  502. * test stripslashes_deep()
  503. *
  504. * @access public
  505. * @return void
  506. */
  507. function testStripslashesDeep() {
  508. $this->skipIf(ini_get('magic_quotes_sybase') === '1', '%s magic_quotes_sybase is on');
  509. $this->assertEqual(stripslashes_deep("tes\'t"), "tes't");
  510. $this->assertEqual(stripslashes_deep('tes\\' . chr(0) .'t'), 'tes' . chr(0) .'t');
  511. $this->assertEqual(stripslashes_deep('tes\"t'), 'tes"t');
  512. $this->assertEqual(stripslashes_deep("tes\'t"), "tes't");
  513. $this->assertEqual(stripslashes_deep('te\\st'), 'test');
  514. $nested = array(
  515. 'a' => "tes\'t",
  516. 'b' => 'tes\\' . chr(0) .'t',
  517. 'c' => array(
  518. 'd' => 'tes\"t',
  519. 'e' => "te\'s\'t",
  520. array('f' => "tes\'t")
  521. ),
  522. 'g' => 'te\\st'
  523. );
  524. $expected = array(
  525. 'a' => "tes't",
  526. 'b' => 'tes' . chr(0) .'t',
  527. 'c' => array(
  528. 'd' => 'tes"t',
  529. 'e' => "te's't",
  530. array('f' => "tes't")
  531. ),
  532. 'g' => 'test'
  533. );
  534. $this->assertEqual(stripslashes_deep($nested), $expected);
  535. }
  536. /**
  537. * test stripslashes_deep() with magic_quotes_sybase on
  538. *
  539. * @access public
  540. * @return void
  541. */
  542. function testStripslashesDeepSybase() {
  543. $this->skipUnless(ini_get('magic_quotes_sybase') === '1', '%s magic_quotes_sybase is off');
  544. $this->assertEqual(stripslashes_deep("tes\'t"), "tes\'t");
  545. $nested = array(
  546. 'a' => "tes't",
  547. 'b' => "tes''t",
  548. 'c' => array(
  549. 'd' => "tes'''t",
  550. 'e' => "tes''''t",
  551. array('f' => "tes''t")
  552. ),
  553. 'g' => "te'''''st"
  554. );
  555. $expected = array(
  556. 'a' => "tes't",
  557. 'b' => "tes't",
  558. 'c' => array(
  559. 'd' => "tes''t",
  560. 'e' => "tes''t",
  561. array('f' => "tes't")
  562. ),
  563. 'g' => "te'''st"
  564. );
  565. $this->assertEqual(stripslashes_deep($nested), $expected);
  566. }
  567. /**
  568. * test ife()
  569. *
  570. * @access public
  571. * @return void
  572. */
  573. function testIfe() {
  574. $this->assertEqual(ife(true, 'a', 'b'), 'a');
  575. $this->assertEqual(ife(' ', 'a', 'b'), 'a');
  576. $this->assertEqual(ife('test', 'a', 'b'), 'a');
  577. $this->assertEqual(ife(23, 'a', 'b'), 'a');
  578. $this->assertEqual(ife(array('t' => 'est'), 'a', 'b'), 'a');
  579. $this->assertEqual(ife(false, 'a', 'b'), 'b');
  580. $this->assertEqual(ife(null, 'a', 'b'), 'b');
  581. $this->assertEqual(ife('', 'a', 'b'), 'b');
  582. $this->assertEqual(ife(0, 'a', 'b'), 'b');
  583. $this->assertEqual(ife(array(), 'a', 'b'), 'b');
  584. }
  585. }
  586. ?>