Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PMA_whichCrlf_test.php « test - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 831bc11b89fa8d6539979b16cef19c822beb710d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Test whichCrlf function
 *
 * @author Michal Biniek <michal@bystrzyca.pl>
 * @package phpMyAdmin-test
 * @version $Id: PMA_whichCrlf_test.php
 */

/**
 * Tests core.
 */
require_once 'PHPUnit/Framework.php';

/**
 * Include to test.
 */
require_once './libraries/common.lib.php';

/**
 * Test whichCrlf function.
 *
 */
class PMA_whichCrlf_test extends PHPUnit_Framework_TestCase
{
    
    /**
     * @using runkit pecl extension
     * if not define PMA_USR_OS, then define it as Win
     * if installed runkit, then constant will not change
     */

    public function testWhichCrlf()
    {
        $runkit = function_exists('runkit_constant_redefine');
        if ($runkit && defined('PMA_USR_OS'))
            $pma_usr_os = PMA_USR_OS;

        if (defined('PMA_USR_OS') && !$runkit) {

            if (PMA_USR_OS == 'Win')
                $this->assertEquals("\r\n", PMA_whichCrlf());
            else
                $this->assertEquals("\n", PMA_whichCrlf());

            $this->markTestIncomplete('Cannot redefine constant');

        } else {

            if ($runkit)
                define('PMA_USR_OS', 'Linux');
            $this->assertEquals("\n", PMA_whichCrlf());

            if ($runkit)
                runkit_constant_redefine('PMA_USR_OS', 'Win');
            else
                define('PMA_USR_OS', 'Win');
            $this->assertEquals("\r\n", PMA_whichCrlf());

        }

        if ($runkit) {
            if (isset($pma_usr_os))
                runkit_constant_redefine('PMA_USR_OS', 'Win');
            else
                runkit_constant_remove('PMA_USR_OS');
        }
    }

}
?>