Fix use of data directory in integration tests

The data directory is not necessarily located at "../..". The proper
directory is now got by running "php console.php config:system:get
datadirectory".

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-02-06 17:55:15 +01:00 committed by Roeland Jago Douma
parent 90fdf83ca7
commit 5a7986c25d
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 23 additions and 2 deletions

View File

@ -356,8 +356,29 @@ trait BasicStructure {
* @param string $text
*/
public function modifyTextOfFile($user, $filename, $text) {
self::removeFile("../../data/$user/files", "$filename");
file_put_contents("../../data/$user/files" . "$filename", "$text");
self::removeFile($this->getDataDirectory() . "/$user/files", "$filename");
file_put_contents($this->getDataDirectory() . "/$user/files" . "$filename", "$text");
}
private function getDataDirectory() {
// Based on "runOcc" from CommandLine trait
$args = ['config:system:get', 'datadirectory'];
$args = array_map(function($arg) {
return escapeshellarg($arg);
}, $args);
$args[] = '--no-ansi --no-warnings';
$args = implode(' ', $args);
$descriptor = [
0 => ['pipe', 'r'],
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('php console.php ' . $args, $descriptor, $pipes, $ocPath = '../..');
$lastStdOut = stream_get_contents($pipes[1]);
proc_close($process);
return trim($lastStdOut);
}
public function createFileSpecificSize($name, $size) {