Skip to content

Commit

Permalink
test(unit) fix pid/running file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Feb 17, 2024
1 parent 3546559 commit c8ffb71
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class BuiltInServerControllerTest extends Unit
private Output $output;

/**
* @beforeClass
* @before
*/
public static function backupPidFile():void{
public function backupPidFile():void{
$pidFile = PhpBuiltInServer::getPidFile();

if (is_file($pidFile)) {
Expand All @@ -54,26 +54,13 @@ public static function backupPidFile():void{
}

/**
* @afterClass
* @after
*/
public static function restorePidFile():void{
$pidFile = PhpBuiltInServer::getPidFile();
$pidFileBackup = $pidFile .'.bak';

if (is_file($pidFileBackup)) {
rename($pidFileBackup, $pidFile);
}
}

/**
* @before
* @after
*/
public function removePidFiles(): void
{
$pidFile = PhpBuiltInServer::getPidFile();
if (is_file($pidFile)) {
unlink($pidFile);
if (is_file($pidFile .'.bak')) {
rename($pidFile.'.bak', $pidFile);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function _before()
}

/**
* @beforeClass
* @before
*/
public static function backupPidFile():void{
public function backupPidFile():void{
$pidFile = ChromeDriver::getPidFile();

if (is_file($pidFile)) {
Expand All @@ -56,14 +56,13 @@ public static function backupPidFile():void{
}

/**
* @afterClass
* @after
*/
public static function restorePidFile():void{
$pidFile = ChromeDriver::getPidFile();
$pidFileBackup = $pidFile .'.bak';

if (is_file($pidFileBackup)) {
rename($pidFileBackup, $pidFile);
if (is_file($pidFile .'.bak')) {
rename($pidFile.'.bak', $pidFile);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,26 @@ public function _before()
}

/**
* @beforeClass
* @before
*/
public static function backupPidFile():void{
$pidFile = DockerComposeController::getRunningFile();
public static function backupRunFile(): void
{
$runFile = DockerComposeController::getRunningFile();

if (is_file($pidFile)) {
rename($pidFile, $pidFile.'.bak');
if (is_file($runFile)) {
rename($runFile, $runFile . '.bak');
}
}

/**
* @afterClass
* @after
*/
public static function restorePidFile():void{
$pidFile = DockerComposeController::getRunningFile();
$pidFileBackup = $pidFile .'.bak';
public static function restoreRunFile(): void
{
$runFile = DockerComposeController::getRunningFile();

if (is_file($pidFileBackup)) {
rename($pidFileBackup, $pidFile);
if (is_file($runFile . '.bak')) {
rename($runFile . '.bak', $runFile);
}
}

Expand Down

0 comments on commit c8ffb71

Please sign in to comment.