2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for several string operations
6 * @author Michal Biniek <michal@bystrzyca.pl>
7 * @version $Id: PMA_stringOperations_test.php
13 require_once 'PHPUnit/Framework.php';
18 require_once './libraries/common.lib.php';
21 * Test string operations.
22 * @package phpMyAdmin-test
24 class PMA_stringOperations_test
extends PHPUnit_Framework_TestCase
28 * temporary variable for globals array
31 protected $tmpGlobals;
34 * temporary variable for session array
37 protected $tmpSession;
40 * storing globals and session
42 public function setUp() {
44 $this->tmpGlobals
= $GLOBALS;
45 $this->tmpSession
= $_SESSION;
50 * data provider for flipstring test
53 public function flipStringDataProvider() {
55 array('test', "t<br />\ne<br />\ns<br />\nt"),
56 array('te ;st', "t<br />\ne<br />\n <br />\n;<br />\ns<br />\nt")
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));
70 * data provider for userDir test
73 public function userDirDataProvider() {
75 array('/var/pma_tmp/%u/', "/var/pma_tmp/root/"),
76 array('/home/%u/pma', "/home/root/pma/")
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));
92 * data provider for replace binary content test
95 public function replaceBinaryContentsDataProvider() {
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() {
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));