Dieser Commit ist enthalten in:
Ursprung
2b21070b1a
Commit
f7a7c71f86
1583 geänderte Dateien mit 454759 neuen und 0 gelöschten Zeilen
61
tests/Testhelper.php
Normale Datei
61
tests/Testhelper.php
Normale Datei
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
class Testhelper
|
||||
{
|
||||
/**
|
||||
* Prepare tests
|
||||
*/
|
||||
public static function setUp()
|
||||
{
|
||||
Testhelper::copyFile(
|
||||
'users.ini', APPLICATION_PATH . DS . 'configs' . DS .'users.ini'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a fixture to destination
|
||||
*
|
||||
* @param string $source Filename of source in fixture folder
|
||||
* @param string $destination Filename of destination
|
||||
* @throws Exception
|
||||
* @return void
|
||||
*/
|
||||
public static function copyFile($source, $destination)
|
||||
{
|
||||
$fixturePath = realpath(dirname(__FILE__) . DS . 'fixtures');
|
||||
$source = realpath($fixturePath . DS . $source);
|
||||
// delete target file if it exists
|
||||
if (file_exists($destination)) {
|
||||
if (!unlink($destination)) {
|
||||
throw new Exception(
|
||||
'Error: Couldn\'t delete file "' . $destination .'"!'
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!copy($source, $destination)) {
|
||||
throw new Exception(
|
||||
'Error: Couldn\'t copy file "' . $source . '" to "'
|
||||
. $destination .'"!'
|
||||
);
|
||||
};
|
||||
chmod($destination, 0755);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a file
|
||||
*
|
||||
* @throws Exception
|
||||
* @param string $file File to remove
|
||||
* @return void
|
||||
*/
|
||||
public function removeFile($file)
|
||||
{
|
||||
if (!file_exists($file)) {
|
||||
return;
|
||||
}
|
||||
if (!unlink($file)) {
|
||||
throw new Exception(
|
||||
'Error: Couldn\'t remove file "' . $file .'"'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren