PMASA-2011-1 fixes
[phpmyadmin-themes.git] / test / PMA_stringOperations_test.php
blob7ed049c46b6f0fd796303a72e710eb2cdf32e650
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for several string operations
6 * @author Michal Biniek <michal@bystrzyca.pl>
7 * @version $Id: PMA_stringOperations_test.php
8 */
10 /**
11 * Tests core.
13 require_once 'PHPUnit/Framework.php';
15 /**
16 * Include to test.
18 require_once './libraries/common.lib.php';
20 /**
21 * Test string operations.
22 * @package phpMyAdmin-test
24 class PMA_stringOperations_test extends PHPUnit_Framework_TestCase
27 /**
28 * temporary variable for globals array
31 protected $tmpGlobals;
33 /**
34 * temporary variable for session array
37 protected $tmpSession;
39 /**
40 * storing globals and session
42 public function setUp() {
44 $this->tmpGlobals = $GLOBALS;
45 $this->tmpSession = $_SESSION;
49 /**
50 * data provider for flipstring test
53 public function flipStringDataProvider() {
54 return array(
55 array('test', "t<br />\ne<br />\ns<br />\nt"),
56 array('te&nbsp;;st', "t<br />\ne<br />\n&nbsp;<br />\n;<br />\ns<br />\nt")
60 /**
61 * test of changing string from horizontal to vertical orientation
62 * @dataProvider flipStringDataProvider
65 public function testFlipString($a, $e) {
66 $this->assertEquals($e, PMA_flipstring($a));
69 /**
70 * data provider for userDir test
73 public function userDirDataProvider() {
74 return array(
75 array('/var/pma_tmp/%u/', "/var/pma_tmp/root/"),
76 array('/home/%u/pma', "/home/root/pma/")
80 /**
81 * test of generating user dir, globals are defined
82 * @dataProvider userDirDataProvider
85 public function testUserDirString($a, $e) {
86 $GLOBALS['cfg']['Server']['user'] = 'root';
88 $this->assertEquals($e, PMA_userDir($a));
91 /**
92 * data provider for replace binary content test
95 public function replaceBinaryContentsDataProvider() {
96 return array(
97 array("\x000", '\00'),
98 array("\x08\x0a\x0d\x1atest", '\b\n\r\Ztest'),
99 array("\ntest", '\ntest')
104 * replace binary contents test
105 * @dataProvider replaceBinaryContentsDataProvider
108 public function testReplaceBinaryContents($a, $e) {
109 $this->assertEquals($e, PMA_replace_binary_contents($a));
113 * data provider for duplicate first newline test
116 public function duplicateFirstNewlineDataProvider() {
117 return array(
118 array('test', 'test'),
119 array("\r\ntest", "\n\r\ntest"),
120 array("\ntest", "\ntest"),
121 array("\n\r\ntest", "\n\r\ntest")
126 * duplicate first newline test
127 * @dataProvider duplicateFirstNewlineDataProvider
130 public function testDuplicateFirstNewline($a, $e) {
131 $this->assertEquals($e, PMA_duplicateFirstNewline($a));