Skip to content

Commit

Permalink
Fix some tests on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Oct 18, 2018
1 parent 3976b37 commit 4c6993b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion libraries/classes/Config.php
Expand Up @@ -458,7 +458,7 @@ public function checkGitRevision(): void
return;
}
// split file to lines
$ref_lines = explode("\n", $packed_refs);
$ref_lines = explode(PHP_EOL, $packed_refs);
foreach ($ref_lines as $line) {
// skip comments
if ($line[0] == '#') {
Expand Down
8 changes: 3 additions & 5 deletions libraries/classes/Engines/Innodb.php
Expand Up @@ -154,11 +154,9 @@ public function getPageBufferpool()
// The following query is only possible because we know
// that we are on MySQL 5 here (checked above)!
// side note: I love MySQL 5 for this. :-)
$sql
= '
SHOW STATUS
WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
OR Variable_name = \'Innodb_page_size\';';
$sql = 'SHOW STATUS'
. ' WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\''
. ' OR Variable_name = \'Innodb_page_size\';';
$status = $GLOBALS['dbi']->fetchResult($sql, 0, 1);

$output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
Expand Down
4 changes: 2 additions & 2 deletions libraries/classes/Utils/HttpRequest.php
Expand Up @@ -174,9 +174,9 @@ private function curl(
*/
if (curl_getinfo($curlHandle, CURLINFO_SSL_VERIFYRESULT) != 0) {
if ($ssl == 0) {
$this->curl($url, $method, $returnOnlyStatus, $content, $header, CURLOPT_CAINFO);
return $this->curl($url, $method, $returnOnlyStatus, $content, $header, CURLOPT_CAINFO);
} elseif ($ssl == CURLOPT_CAINFO) {
$this->curl($url, $method, $returnOnlyStatus, $content, $header, CURLOPT_CAPATH);
return $this->curl($url, $method, $returnOnlyStatus, $content, $header, CURLOPT_CAPATH);
}
}
return null;
Expand Down
8 changes: 3 additions & 5 deletions test/classes/ConfigTest.php
Expand Up @@ -785,16 +785,14 @@ public function testCheckPermissions()

//load file permissions for the current permissions file
$perms = @fileperms($this->permTestObj->getSource());
//testing for permissions
$this->assertFalse(!($perms === false) && ($perms & 2));

//if the above assertion is false then applying further assertions
if (!($perms === false) && ($perms & 2)) {
$this->assertNotSame(0, $this->permTestObj->get('PMA_IS_WINDOWS'));
$this->assertTrue((bool) $this->permTestObj->get('PMA_IS_WINDOWS'));
} else {
$this->assertFalse((bool) $this->permTestObj->get('PMA_IS_WINDOWS'));
}
}


/**
* Test for setting cookies
*
Expand Down
24 changes: 12 additions & 12 deletions test/classes/Display/ResultsTest.php
Expand Up @@ -1526,12 +1526,12 @@ public function dataProviderForTestGetDataCellForNonNumericColumns()
[],
0,
'binary',
'<td class="left hex">' . PHP_EOL
'<td class="left hex">' . "\n"
. ' <a href="tbl_get_field.php?'
. 'db=foo&amp;table=tbl&amp;server=0&amp;lang=en'
. '" '
. 'class="disableAjax">[BLOB - 4 B]</a>' . PHP_EOL
. '</td>' . PHP_EOL
. 'class="disableAjax">[BLOB - 4 B]</a>' . "\n"
. '</td>' . "\n"
],
[
'noblob',
Expand All @@ -1548,9 +1548,9 @@ public function dataProviderForTestGetDataCellForNonNumericColumns()
[],
0,
'binary',
'<td class="left grid_edit transformed hex">' . PHP_EOL
. ' 1001' . PHP_EOL
. '</td>' . PHP_EOL
'<td class="left grid_edit transformed hex">' . "\n"
. ' 1001' . "\n"
. '</td>' . "\n"
],
[
'noblob',
Expand All @@ -1567,12 +1567,12 @@ public function dataProviderForTestGetDataCellForNonNumericColumns()
[],
0,
0,
'<td ' . PHP_EOL
. ' data-decimals="0"' . PHP_EOL
. ' data-type="string"' . PHP_EOL
. ' class="grid_edit null">' . PHP_EOL
. ' <em>NULL</em>' . PHP_EOL
. '</td>' . PHP_EOL
'<td ' . "\n"
. ' data-decimals="0"' . "\n"
. ' data-type="string"' . "\n"
. ' class="grid_edit null">' . "\n"
. ' <em>NULL</em>' . "\n"
. '</td>' . "\n"
],
[
'all',
Expand Down
7 changes: 5 additions & 2 deletions test/classes/ErrorTest.php
Expand Up @@ -98,8 +98,11 @@ public function testSetFile($file, $expected)
public function filePathProvider()
{
return [
['./ChangeLog', './ChangeLog'],
[__FILE__, './test/classes/ErrorTest.php'],
['./ChangeLog', '.' . DIRECTORY_SEPARATOR . 'ChangeLog'],
[
__FILE__,
'.' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'ErrorTest.php'
],
['./NONEXISTING', 'NONEXISTING'],
];
}
Expand Down
46 changes: 23 additions & 23 deletions test/classes/ZipExtensionTest.php
Expand Up @@ -148,14 +148,15 @@ public function testExtract()
}

/**
* Helper function to get ZipArchive for content.
*
* @param mixed $file file
* Test for createFile
*
* @return ZipArchive
* @return void
*/
private function getZip($file)
public function testCreateSingleFile()
{
$file = $this->zipExtension->createFile("Test content", "test.txt");
$this->assertNotEmpty($file);

$tmp = tempnam('./', 'zip-test');
$handle = fopen($tmp, 'w');
fwrite($handle, $file);
Expand All @@ -166,24 +167,10 @@ private function getZip($file)
$zip->open($tmp)
);

unlink($tmp);

return $zip;
}

/**
* Test for createFile
*
* @return void
*/
public function testCreateSingleFile()
{
$file = $this->zipExtension->createFile("Test content", "test.txt");
$this->assertNotEmpty($file);

$zip = $this->getZip($file);

$this->assertEquals(0, $zip->locateName('test.txt'));

$zip->close();
unlink($tmp);
}

/**
Expand Down Expand Up @@ -214,8 +201,21 @@ public function testCreateMultiFile()
["name1.txt", "name2.txt"]
);
$this->assertNotEmpty($file);
$zip = $this->getZip($file);

$tmp = tempnam('./', 'zip-test');
$handle = fopen($tmp, 'w');
fwrite($handle, $file);
fclose($handle);

$zip = new ZipArchive();
$this->assertTrue(
$zip->open($tmp)
);

$this->assertEquals(0, $zip->locateName('name1.txt'));
$this->assertEquals(1, $zip->locateName('name2.txt'));

$zip->close();
unlink($tmp);
}
}

0 comments on commit 4c6993b

Please sign in to comment.