mirror of
https://github.com/danog/tgseclib.git
synced 2024-11-26 20:24:39 +01:00
Introduce abstract class for functional tests.
This commit is contained in:
parent
c1597f4533
commit
ea31d9d38c
47
tests/PhpseclibFunctionalTestCase.php
Normal file
47
tests/PhpseclibFunctionalTestCase.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Andreas Fischer <bantu@phpbb.com>
|
||||
* @copyright MMXIV Andreas Fischer
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
abstract class PhpseclibFunctionalTestCase extends PhpseclibTestCase
|
||||
{
|
||||
/**
|
||||
* @param string $variable
|
||||
* @param string|null $message
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function requireEnv($variable, $message = null)
|
||||
{
|
||||
if ($this->_getEnv($variable) === false) {
|
||||
$msg = $message ? $message : sprintf(
|
||||
"This test requires the '%s' environment variable.",
|
||||
$this->_prefixEnvVariable($variable)
|
||||
);
|
||||
$this->markTestSkipped($msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $variable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEnv($variable)
|
||||
{
|
||||
$this->requireEnv($variable);
|
||||
return $this->_getEnv($variable);
|
||||
}
|
||||
|
||||
private function _getEnv($variable)
|
||||
{
|
||||
return getenv($this->_prefixEnvVariable($variable));
|
||||
}
|
||||
|
||||
private function _prefixEnvVariable($variable)
|
||||
{
|
||||
return 'PHPSECLIB_' . $variable;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user