2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for several string operations
6 * @version $Id: PMA_stringOperations_test.php
12 require_once 'PHPUnit/Framework.php';
17 require_once './libraries/common.lib.php';
20 * Test string operations.
21 * @package phpMyAdmin-test
23 class PMA_stringOperations_test
extends PHPUnit_Framework_TestCase
27 * temporary variable for globals array
30 protected $tmpGlobals;
33 * temporary variable for session array
36 protected $tmpSession;
39 * storing globals and session
41 public function setUp() {
43 $this->tmpGlobals
= $GLOBALS;
44 $this->tmpSession
= $_SESSION;
49 * data provider for flipstring test
52 public function flipStringDataProvider() {
54 array('test', "t<br />\ne<br />\ns<br />\nt"),
55 array('te ;st', "t<br />\ne<br />\n <br />\n;<br />\ns<br />\nt")
60 * test of changing string from horizontal to vertical orientation
61 * @dataProvider flipStringDataProvider
64 public function testFlipString($a, $e) {
65 $this->assertEquals($e, PMA_flipstring($a));
69 * data provider for userDir test
72 public function userDirDataProvider() {
74 array('/var/pma_tmp/%u/', "/var/pma_tmp/root/"),
75 array('/home/%u/pma', "/home/root/pma/")
80 * test of generating user dir, globals are defined
81 * @dataProvider userDirDataProvider
84 public function testUserDirString($a, $e) {
85 $GLOBALS['cfg']['Server']['user'] = 'root';
87 $this->assertEquals($e, PMA_userDir($a));
91 * data provider for replace binary content test
94 public function replaceBinaryContentsDataProvider() {
96 array("\x000", '\00'),
97 array("\x08\x0a\x0d\x1atest", '\b\n\r\Ztest'),
98 array("\ntest", '\ntest')
103 * replace binary contents test
104 * @dataProvider replaceBinaryContentsDataProvider
107 public function testReplaceBinaryContents($a, $e) {
108 $this->assertEquals($e, PMA_replace_binary_contents($a));
112 * data provider for duplicate first newline test
115 public function duplicateFirstNewlineDataProvider() {
117 array('test', 'test'),
118 array("\r\ntest", "\n\r\ntest"),
119 array("\ntest", "\ntest"),
120 array("\n\r\ntest", "\n\r\ntest")
125 * duplicate first newline test
126 * @dataProvider duplicateFirstNewlineDataProvider
129 public function testDuplicateFirstNewline($a, $e) {
130 $this->assertEquals($e, PMA_duplicateFirstNewline($a));