2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for several string operations
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_stringOperations_test.php
8 * @group common.lib-tests
14 require_once 'libraries/common.lib.php';
16 class PMA_stringOperations_test
extends PHPUnit_Framework_TestCase
20 * temporary variable for globals array
23 protected $tmpGlobals;
26 * temporary variable for session array
29 protected $tmpSession;
32 * storing globals and session
34 public function setUp() {
36 global $GLOBALS, $_SESSION;
37 $this->tmpGlobals
= $GLOBALS;
38 $this->tmpSession
= $_SESSION;
43 * data provider for flipstring test
47 public function flipStringDataProvider() {
49 array('test', "t<br />\ne<br />\ns<br />\nt"),
50 array('te ;st', "t<br />\ne<br />\n <br />\n;<br />\ns<br />\nt")
55 * test of changing string from horizontal to vertical orientation
56 * @dataProvider flipStringDataProvider
59 public function testFlipString($a, $e) {
60 $this->assertEquals($e, PMA_flipstring($a));
64 * data provider for userDir test
68 public function userDirDataProvider() {
70 array('/var/pma_tmp/%u/', "/var/pma_tmp/root/"),
71 array('/home/%u/pma', "/home/root/pma/")
76 * test of generating user dir, globals are defined
77 * @dataProvider userDirDataProvider
80 public function testUserDirString($a, $e) {
81 $GLOBALS['cfg']['Server']['user'] = 'root';
83 $this->assertEquals($e, PMA_userDir($a));
87 * data provider for replace binary content test
91 public function replaceBinaryContentsDataProvider() {
93 array("\x000", '\00'),
94 array("\x08\x0a\x0d\x1atest", '\b\n\r\Ztest'),
95 array("\ntest", '\ntest')
100 * replace binary contents test
101 * @dataProvider replaceBinaryContentsDataProvider
104 public function testReplaceBinaryContents($a, $e) {
105 $this->assertEquals($e, PMA_replace_binary_contents($a));
109 * data provider for duplicate first newline test
113 public function duplicateFirstNewlineDataProvider() {
115 array('test', 'test'),
116 array("\r\ntest", "\n\r\ntest"),
117 array("\ntest", "\ntest"),
118 array("\n\r\ntest", "\n\r\ntest")
123 * duplicate first newline test
124 * @dataProvider duplicateFirstNewlineDataProvider
127 public function testDuplicateFirstNewline($a, $e) {
128 $this->assertEquals($e, PMA_duplicateFirstNewline($a));