Merge pull request #12919 from nijel/php-eol

Replace Util::whichCrlf() with PHP_EOL
This commit is contained in:
Michal Čihař 2017-01-23 17:12:22 +01:00 committed by GitHub
commit 9a3ec234c5
4 changed files with 2 additions and 110 deletions

View File

@ -312,7 +312,7 @@ $time_start = time();
if ($what == 'sql') {
$crlf = "\n";
} else {
$crlf = PMA\libraries\Util::whichCrlf();
$crlf = PHP_EOL;
}
$output_kanji_conversion = Encoding::canConvertKanji();

View File

@ -933,27 +933,6 @@ class Util
}
} // end of the 'backquoteCompat()' function
/**
* Defines the <CR><LF> value depending on the user OS.
*
* @return string the <CR><LF> value to use
*
* @access public
*/
public static function whichCrlf()
{
// The 'PMA_USR_OS' constant is defined in "libraries/Config.php"
// Win case
if (PMA_USR_OS == 'Win') {
$the_crlf = "\r\n";
} else {
// Others
$the_crlf = "\n";
}
return $the_crlf;
} // end of the 'whichCrlf()' function
/**
* Prepare the message and the query
* usually the message is the result of the query executed

View File

@ -142,7 +142,7 @@ class ImportLdi extends AbstractImportCsv
if (strlen($ldi_new_line) > 0) {
if ($ldi_new_line == 'auto') {
$ldi_new_line
= (PMA\libraries\Util::whichCrlf() == "\n")
= (PHP_EOL == "\n")
? '\n'
: '\r\n';
}

View File

@ -1,87 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test PMA\libraries\Util::whichCrlf function
*
* @package PhpMyAdmin-test
* @group common.lib-tests
*/
/*
* Include to test.
*/
/**
* Test PMA\libraries\Util::whichCrlf function
*
* @package PhpMyAdmin-test
* @group common.lib-tests
*/
class PMA_WhichCrlf_Test extends PHPUnit_Framework_TestCase
{
/**
* Test for whichCrlf
*
* @return void
*
* @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()
{
if (PMA_HAS_RUNKIT && defined('PMA_USR_OS')) {
$pma_usr_os = PMA_USR_OS;
}
if (defined('PMA_USR_OS') && !PMA_HAS_RUNKIT) {
if (PMA_USR_OS == 'Win') {
$this->assertEquals(
"\r\n", PMA\libraries\Util::whichCrlf()
);
} else {
$this->assertEquals(
"\n", PMA\libraries\Util::whichCrlf()
);
}
$this->markTestIncomplete('Cannot redefine constant');
} else {
if (PMA_HAS_RUNKIT) {
if (!defined('PMA_USR_OS')) {
define('PMA_USR_OS', 'Linux');
} else {
runkit_constant_redefine('PMA_USR_OS', 'Linux');
}
$this->assertEquals(
"\n", PMA\libraries\Util::whichCrlf()
);
}
if (PMA_HAS_RUNKIT) {
runkit_constant_redefine('PMA_USR_OS', 'Win');
} else {
define('PMA_USR_OS', 'Win');
}
$this->assertEquals(
"\r\n", PMA\libraries\Util::whichCrlf()
);
}
if (PMA_HAS_RUNKIT) {
if (isset($pma_usr_os)) {
runkit_constant_redefine('PMA_USR_OS', 'Win');
} else {
runkit_constant_remove('PMA_USR_OS');
}
}
}
}