This commit is contained in:
kremsy 2017-04-16 16:41:30 +02:00
parent 653ee5b577
commit 01bc21e37b
6 changed files with 40 additions and 9 deletions

View File

@ -26,7 +26,7 @@ abstract class BackupUtil {
} }
$time = date('y-m-d_H-i-s'); $time = date('y-m-d_H-i-s');
if(defined('PHP_UNIT_TEST')){ if (defined('PHP_UNIT_TEST')) {
$time = date('y-m-d_H-i'); $time = date('y-m-d_H-i');
} }
@ -82,7 +82,7 @@ abstract class BackupUtil {
} }
$useBaseFileNames = !empty($baseFileNames); $useBaseFileNames = !empty($baseFileNames);
while (false !== ($file = readdir($folderHandle))) { while (false !== ($file = readdir($folderHandle))) {
if (substr($file, 0, 1) === '.') { if (FileUtil::isHiddenFile($file)) {
// Skip such .files // Skip such .files
continue; continue;
} }

View File

@ -4,7 +4,6 @@ namespace ManiaControl\Files;
use ManiaControl\Logger; use ManiaControl\Logger;
use ManiaControl\Utils\Formatter; use ManiaControl\Utils\Formatter;
use ManiaControl\Utils\SystemUtil;
use ManiaControl\Utils\WebReader; use ManiaControl\Utils\WebReader;
/** /**
@ -131,7 +130,7 @@ abstract class FileUtil {
foreach ($directories as $directory) { foreach ($directories as $directory) {
$dir = new \RecursiveDirectoryIterator(MANIACONTROL_PATH . $directory); $dir = new \RecursiveDirectoryIterator(MANIACONTROL_PATH . $directory);
foreach (new \RecursiveIteratorIterator($dir) as $fileName => $file) { foreach (new \RecursiveIteratorIterator($dir) as $fileName => $file) {
if (substr($fileName, 0, 1) === '.') { if (self::isHiddenFile($fileName)) {
continue; continue;
} }
if (!is_writable($fileName)) { if (!is_writable($fileName)) {
@ -227,4 +226,14 @@ abstract class FileUtil {
return $className; return $className;
} }
/**
* Checks if a File is Hidden
*
* @param $fileName
* @return bool
*/
public static function isHiddenFile($fileName) {
return (substr($fileName, 0, 1) === '.');
}
} }

View File

@ -11,6 +11,7 @@ use FML\Controls\Quads\Quad_UIConstruction_Buttons;
use FML\Controls\Quads\Quad_UIConstructionBullet_Buttons; use FML\Controls\Quads\Quad_UIConstructionBullet_Buttons;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Script\Features\Paging; use FML\Script\Features\Paging;
use ManiaControl\Files\FileUtil;
use ManiaControl\Logger; use ManiaControl\Logger;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
@ -246,7 +247,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$mapFiles = array(); $mapFiles = array();
$dirFiles = scandir($directory); $dirFiles = scandir($directory);
foreach ($dirFiles as $fileName) { foreach ($dirFiles as $fileName) {
if (substr($fileName, 0, 1) === '.') { if (FileUtil::isHiddenFile($fileName)) {
continue; continue;
} }
$fullFileName = $directory . $fileName; $fullFileName = $directory . $fileName;

View File

@ -121,8 +121,8 @@ class PluginManager {
return false; return false;
} }
$reflector = new ReflectionClass($pluginClass); $reflector = new ReflectionClass($pluginClass);
$className = $pluginClass; $className = $pluginClass;
$splitNameSpace = explode('\\', $pluginClass); $splitNameSpace = explode('\\', $pluginClass);
if (is_array($splitNameSpace)) { if (is_array($splitNameSpace)) {
$className = end($splitNameSpace); $className = end($splitNameSpace);
@ -297,7 +297,7 @@ class PluginManager {
} }
$pluginFiles = scandir($directory); $pluginFiles = scandir($directory);
foreach ($pluginFiles as $pluginFile) { foreach ($pluginFiles as $pluginFile) {
if (substr($pluginFile, 0, 1) === '.') { if (FileUtil::isHiddenFile($pluginFile)) {
continue; continue;
} }

View File

@ -30,7 +30,7 @@ abstract class WebReader {
} }
return $response; return $response;
} }
/** /**
* Create a new cURL Request for the given URL * Create a new cURL Request for the given URL
* *

View File

@ -0,0 +1,21 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 16. Apr. 2017
* Time: 15:38
*/
use ManiaControl\Utils\SystemUtil;
class SystemUtilTest extends PHPUnit_Framework_TestCase {
public function testCheckRequirements() {
SystemUtil::checkRequirements();
$this->assertContains("Checking for minimum required PHP-Version 5.4", $this->getActualOutput());
$this->assertContains("Checking for installed MySQLi ... FOUND!", $this->getActualOutput());
$this->assertContains("Checking for installed cURL ... FOUND!", $this->getActualOutput());
$this->assertContains("Checking for installed PHP ZIP ... FOUND!", $this->getActualOutput());
$this->assertContains("Checking for installed Zlib ... FOUND!", $this->getActualOutput());
}
}