Advisor: mark that 'Rate of reading fixed position' may be wrong, requires further...
[phpmyadmin/thilanka.git] / test / libraries / common / PMA_stringOperations_test.php
blob3664b4407033172e0550075fe271b085e5acb12c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for several string operations
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_stringOperations_test.php
8 * @group common.lib-tests
9 */
12 * Include to test.
14 require_once 'libraries/common.lib.php';
16 class PMA_stringOperations_test extends PHPUnit_Framework_TestCase
19 /**
20 * temporary variable for globals array
23 protected $tmpGlobals;
25 /**
26 * temporary variable for session array
29 protected $tmpSession;
31 /**
32 * storing globals and session
34 public function setUp() {
36 global $GLOBALS, $_SESSION;
37 $this->tmpGlobals = $GLOBALS;
38 $this->tmpSession = $_SESSION;
42 /**
43 * data provider for flipstring test
45 * @return array
47 public function flipStringDataProvider() {
48 return array(
49 array('test', "t<br />\ne<br />\ns<br />\nt"),
50 array('te&nbsp;;st', "t<br />\ne<br />\n&nbsp;<br />\n;<br />\ns<br />\nt")
54 /**
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));
63 /**
64 * data provider for userDir test
66 * @return array
68 public function userDirDataProvider() {
69 return array(
70 array('/var/pma_tmp/%u/', "/var/pma_tmp/root/"),
71 array('/home/%u/pma', "/home/root/pma/")
75 /**
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));
86 /**
87 * data provider for replace binary content test
89 * @return array
91 public function replaceBinaryContentsDataProvider() {
92 return array(
93 array("\x000", '\00'),
94 array("\x08\x0a\x0d\x1atest", '\b\n\r\Ztest'),
95 array("\ntest", '\ntest')
99 /**
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
111 * @return array
113 public function duplicateFirstNewlineDataProvider() {
114 return array(
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));