Commit 2635737a authored by Marc Egger's avatar Marc Egger
Browse files

Refs #11926 : use alternate form and report directories for phpunit (form_phpunit)

parent 86697ebb
Pipeline #4987 passed with stages
in 4 minutes and 21 seconds
...@@ -606,7 +606,7 @@ class FormAsFile ...@@ -606,7 +606,7 @@ class FormAsFile
*/ */
private static function formPath(Database $database): string private static function formPath(Database $database): string
{ {
$absoluteFormPath = Path::absoluteProject(Path::PROJECT_TO_FORM); $absoluteFormPath = Path::absoluteProject(Path::projectToForm());
if (!is_dir($absoluteFormPath)) { if (!is_dir($absoluteFormPath)) {
// create path // create path
...@@ -771,7 +771,7 @@ class FormAsFile ...@@ -771,7 +771,7 @@ class FormAsFile
private static function newBackupPathFileName(string $formName, string $tag): string private static function newBackupPathFileName(string $formName, string $tag): string
{ {
// create backup path if not exists // create backup path if not exists
$absoluteBackupPath = Path::absoluteProject(Path::PROJECT_TO_FORM, Path::FORM_TO_FORM_BACKUP); $absoluteBackupPath = Path::absoluteProject(Path::projectToForm(), Path::FORM_TO_FORM_BACKUP);
if (!is_dir($absoluteBackupPath)) { if (!is_dir($absoluteBackupPath)) {
$success = mkdir($absoluteBackupPath, 0777, true); $success = mkdir($absoluteBackupPath, 0777, true);
if ($success === false) { if ($success === false) {
......
...@@ -457,7 +457,7 @@ class HelperFile { ...@@ -457,7 +457,7 @@ class HelperFile {
} }
if (isset($extToFileType[$ext])) { if (isset($extToFileType[$ext])) {
return Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/' . $extToFileType[$ext]; return Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/' . $extToFileType[$ext];
} }
return ''; return '';
......
...@@ -43,20 +43,24 @@ class Path ...@@ -43,20 +43,24 @@ class Path
const EXT_TO_PATH_ICONS = 'Resources/Public/icons'; const EXT_TO_PATH_ICONS = 'Resources/Public/icons';
// Annotate // Annotate
const EXT_TO_HIGHLIGHT_JSON_DIR = 'Resources/Public/Json'; // TODO: refactor: remove DIR at the end of the constant name const EXT_TO_HIGHLIGHT_JSON = 'Resources/Public/Json';
// Twig // Twig
const EXT_TO_TWIG_TEMPLATES = 'Resources/Public/twig_templates'; const EXT_TO_TWIG_TEMPLATES = 'Resources/Public/twig_templates';
// QFQ Project dir // QFQ Project dir
private static $appToProject = null; private static $appToProject = null;
private const APP_TO_PROJECT_DEFAULT = '../'; private static $projectToForm = null;
private static $projectToReport = null;
private const APP_TO_PROJECT_DEFAULT = '../'; // Don't use directly, use appToProject()
private const APP_TO_FILEADMIN = 'fileadmin'; private const APP_TO_FILEADMIN = 'fileadmin';
private const APP_TO_PROJECT_IN_PROTECTED = 'fileadmin/protected/qfqProject'; private const APP_TO_PROJECT_IN_PROTECTED = 'fileadmin/protected/qfqProject'; // Don't use directly, use appToProject()
const PROJECT_TO_FORM = 'form';
const PROJECT_TO_CONF = 'conf'; const PROJECT_TO_CONF = 'conf';
const PROJECT_TO_FORM_DEFAULT = 'form'; // Don't use directly, use projectToForm()
const PROJECT_TO_FORM_PHPUNIT = 'form_phpunit'; // Don't use directly, use projectToForm()
const FORM_TO_FORM_BACKUP = '.backup'; const FORM_TO_FORM_BACKUP = '.backup';
const PROJECT_DIR_TO_REPORT = 'report'; // TODO: refactor: remove DIR from constant name const PROJECT_TO_REPORT_DEFAULT = 'report'; // Don't use directly, use projectToReport()
const PROJECT_TO_REPORT_PHPUNIT = 'report_phpunit'; // Don't use directly, use projectToReport()
const REPORT_FILE_TO_BACKUP = '.backup'; // The path from a directory containing a report file to the directory containing backups of that report file const REPORT_FILE_TO_BACKUP = '.backup'; // The path from a directory containing a report file to the directory containing backups of that report file
// Config // Config
...@@ -67,11 +71,11 @@ class Path ...@@ -67,11 +71,11 @@ class Path
private static $overloadAbsoluteQfqLogFile = null; private static $overloadAbsoluteQfqLogFile = null;
private static $overloadAbsoluteMailLogFile = null; private static $overloadAbsoluteMailLogFile = null;
private static $overloadAbsoluteSqlLogFile = null; private static $overloadAbsoluteSqlLogFile = null;
private const LOG_TO_QFQ_LOG_FILE_DEFAULT = 'qfq.log'; private const LOG_TO_QFQ_LOG_FILE_DEFAULT = 'qfq.log'; // Don't use directly, use absoluteQfqLogFile()
private const LOG_TO_MAIL_LOG_FILE_DEFAULT = 'mail.log'; private const LOG_TO_MAIL_LOG_FILE_DEFAULT = 'mail.log'; // Don't use directly, use absoluteMailLogFile()
private const LOG_TO_SQL_LOG_FILE_DEFAULT = 'sql.log'; private const LOG_TO_SQL_LOG_FILE_DEFAULT = 'sql.log'; // Don't use directly, use absoluteSqlLogFile()
private const PROJECT_TO_LOG_DEFAULT = 'log'; private const PROJECT_TO_LOG_DEFAULT = 'log'; // Don't use directly, use absoluteLog()
private const APP_TO_LOG_IN_PROTECTED = 'fileadmin/protected/log'; private const APP_TO_LOG_IN_PROTECTED = 'fileadmin/protected/log'; // Don't use directly, use absoluteLog()
// Thumbnail // Thumbnail
const APP_TO_SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT = 'fileadmin/protected/qfqThumbnail'; const APP_TO_SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT = 'fileadmin/protected/qfqThumbnail';
...@@ -233,6 +237,42 @@ class Path ...@@ -233,6 +237,42 @@ class Path
return self::join(self::APP_TO_EXT, self::EXT_TO_API, $pathPartsToAppend); return self::join(self::APP_TO_EXT, self::EXT_TO_API, $pathPartsToAppend);
} }
/**
* @param mixed ...$pathPartsToAppend
* @return string
*/
public static function projectToForm(...$pathPartsToAppend) : string
{
$projectToForm = is_null(self::$projectToForm) ? self::PROJECT_TO_FORM_DEFAULT : self::$projectToForm;
return self::join($projectToForm, $pathPartsToAppend);
}
/**
* @param mixed ...$pathPartsToAppend
* @return string
*/
public static function projectToReport(...$pathPartsToAppend) : string
{
$projectToReport = is_null(self::$projectToReport) ? self::PROJECT_TO_REPORT_DEFAULT : self::$projectToReport;
return self::join($projectToReport, $pathPartsToAppend);
}
/**
* @param string $newPath
*/
public static function setProjectToForm(string $newPath)
{
self::$projectToForm = $newPath;
}
/**
* @param string $newPath
*/
public static function setProjectToReport(string $newPath)
{
self::$projectToReport = $newPath;
}
/** /**
* @param string $newPath * @param string $newPath
* @throws \UserFormException * @throws \UserFormException
......
...@@ -239,7 +239,7 @@ class ReportAsFile ...@@ -239,7 +239,7 @@ class ReportAsFile
*/ */
private static function reportPath(): string private static function reportPath(): string
{ {
$absoluteReportPath = Path::absoluteProject(Path::PROJECT_DIR_TO_REPORT); $absoluteReportPath = Path::absoluteProject(Path::projectToReport());
HelperFile::createPathRecursive($absoluteReportPath); HelperFile::createPathRecursive($absoluteReportPath);
return $absoluteReportPath; return $absoluteReportPath;
} }
......
...@@ -33,21 +33,21 @@ class HelperFileTest extends TestCase { ...@@ -33,21 +33,21 @@ class HelperFileTest extends TestCase {
$this->assertEquals('', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO,'')); $this->assertEquals('', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ,'')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON,'')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB,'')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'fileadmin/test.js')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ, 'fileadmin/test.js')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON, 'fileadmin/test.js')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB, 'fileadmin/test.js')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.js')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.php.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.php')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.php.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.php'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.qfq')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.qfq'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.py')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.py'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m')); $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m'));
} }
public function testJoinPathFilename() { public function testJoinPathFilename() {
......
...@@ -4,4 +4,6 @@ use IMATHUZH\Qfq\Core\Helper\Path; ...@@ -4,4 +4,6 @@ use IMATHUZH\Qfq\Core\Helper\Path;
require dirname(__DIR__).'/vendor/autoload.php'; require dirname(__DIR__).'/vendor/autoload.php';
Path::setMainPaths('TODO'); // TODO: replace relative path ../../../ with absolute Path::setProjectToForm(Path::PROJECT_TO_FORM_PHPUNIT);
\ No newline at end of file Path::setProjectToReport(Path::PROJECT_TO_REPORT_PHPUNIT);
Path::setMainPaths();
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment