mirror of https://github.com/hauke68/Magallanes
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.6 KiB
83 lines
1.6 KiB
8 years ago
|
<?php
|
||
8 years ago
|
/*
|
||
|
* This file is part of the Magallanes package.
|
||
|
*
|
||
|
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||
|
*
|
||
|
* For the full copyright and license information, please view the LICENSE
|
||
|
* file that was distributed with this source code.
|
||
|
*/
|
||
|
|
||
8 years ago
|
namespace Mage\Tests\Runtime;
|
||
|
|
||
|
use Mage\Runtime\Runtime;
|
||
|
use Symfony\Component\Process\Process;
|
||
|
|
||
|
class RuntimeMockup extends Runtime
|
||
|
{
|
||
|
protected $ranCommands = [];
|
||
8 years ago
|
protected $forceFail = [];
|
||
8 years ago
|
|
||
|
public function getRanCommands()
|
||
|
{
|
||
|
return $this->ranCommands;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Generate the Release ID
|
||
|
*
|
||
8 years ago
|
* @return Runtime
|
||
8 years ago
|
*/
|
||
|
public function generateReleaseId()
|
||
|
{
|
||
|
$this->setReleaseId('1234567890');
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Execute a command locally
|
||
|
*
|
||
|
* @param string $cmd Command to execute
|
||
|
* @param int $timeout Seconds to wait
|
||
|
* @return Process
|
||
|
*/
|
||
|
public function runLocalCommand($cmd, $timeout = 120)
|
||
|
{
|
||
|
$this->ranCommands[] = $cmd;
|
||
|
|
||
|
$process = new ProcessMockup($cmd);
|
||
8 years ago
|
$process->forceFail = $this->forceFail;
|
||
8 years ago
|
$process->setTimeout($timeout);
|
||
|
$process->run();
|
||
|
|
||
|
return $process;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Gets a Temporal File name
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getTempFile()
|
||
|
{
|
||
|
return '/tmp/mageXYZ';
|
||
|
}
|
||
8 years ago
|
|
||
|
/**
|
||
|
* Allows to set an invalid environments
|
||
|
*
|
||
|
* @param string $environment
|
||
|
* @return Runtime
|
||
|
*/
|
||
|
public function setInvalidEnvironment($environment)
|
||
|
{
|
||
|
$this->environment = $environment;
|
||
|
return $this;
|
||
|
}
|
||
8 years ago
|
|
||
|
public function forceFail($cmd)
|
||
|
{
|
||
|
$this->forceFail[] = $cmd;
|
||
|
}
|
||
8 years ago
|
}
|