1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-15 10:26:59 +01:00
phpseclib/tests/PhpseclibFunctionalTestCase.php

48 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2022-02-17 03:25:59 +01:00
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2014 Andreas Fischer
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
2022-06-04 17:31:21 +02:00
declare(strict_types=1);
namespace phpseclib3\Tests;
2014-12-17 01:16:54 +01:00
abstract class PhpseclibFunctionalTestCase extends PhpseclibTestCase
{
/**
2015-03-29 18:07:17 +02:00
* @return null
*/
2022-06-04 17:31:21 +02:00
protected function requireEnv(string $variable, string $message = null)
{
if ($this->_getEnv($variable) === false) {
$msg = $message ? $message : sprintf(
"This test requires the '%s' environment variable.",
$this->_prefixEnvVariable($variable)
);
$this->markTestSkipped($msg);
}
}
/**
2015-03-29 18:07:17 +02:00
*
*/
2022-06-04 17:31:21 +02:00
protected function getEnv(string $variable): string
{
$this->requireEnv($variable);
return $this->_getEnv($variable);
}
private function _getEnv($variable)
{
return getenv($this->_prefixEnvVariable($variable));
}
2022-06-04 17:31:21 +02:00
private function _prefixEnvVariable($variable): string
{
return 'PHPSECLIB_' . $variable;
}
}