diff options
| author | Loic GUEGAN <loic@Manzerbredes.home> | 2016-04-16 19:10:27 +0200 |
|---|---|---|
| committer | Loic GUEGAN <loic@Manzerbredes.home> | 2016-04-16 19:10:27 +0200 |
| commit | a3ff4d243e2ac37d4516ae56ff86985eadc00eb8 (patch) | |
| tree | 32e71c42855cc46d95d9c6b74ad2c145eb9ec7eb /server/vendor/php-opencloud/common/tests/integration/SampleManager.php | |
| parent | 396c90f921c30de2d15d2ce52d5d1beabf8eb52d (diff) | |
| parent | 31d2d0c158ad4daa3dde7a905f3c2e312c194f2e (diff) | |
Test
Diffstat (limited to 'server/vendor/php-opencloud/common/tests/integration/SampleManager.php')
| -rwxr-xr-x | server/vendor/php-opencloud/common/tests/integration/SampleManager.php | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/server/vendor/php-opencloud/common/tests/integration/SampleManager.php b/server/vendor/php-opencloud/common/tests/integration/SampleManager.php deleted file mode 100755 index 4bd8b9a..0000000 --- a/server/vendor/php-opencloud/common/tests/integration/SampleManager.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php - -namespace OpenCloud\integration; - -class SampleManager implements SampleManagerInterface -{ - protected $basePath; - protected $paths = []; - protected $verbosity; - - public function __construct($basePath, $verbosity) - { - $this->basePath = $basePath; - $this->verbosity = $verbosity; - } - - public function deletePaths() - { - if (!empty($this->paths)) { - foreach ($this->paths as $path) { - unlink($path); - } - } - } - - protected function getGlobalReplacements() - { - return [ - '{userId}' => getenv('OS_USER_ID'), - '{username}' => getenv('OS_USERNAME'), - '{password}' => getenv('OS_PASSWORD'), - '{domainId}' => getenv('OS_DOMAIN_ID'), - '{authUrl}' => getenv('OS_AUTH_URL'), - '{tenantId}' => getenv('OS_TENANT_ID'), - '{region}' => getenv('OS_REGION'), - '{projectId}' => getenv('OS_PROJECT_ID'), - '{projectName}' => getenv('OS_PROJECT_NAME'), - ]; - } - - protected function getConnectionTemplate() - { - if ($this->verbosity === 1) { - $subst = <<<'EOL' -use OpenCloud\Integration\DefaultLogger; -use OpenCloud\Integration\Utils; -use GuzzleHttp\MessageFormatter; - -$options = [ - 'debugLog' => true, - 'logger' => new DefaultLogger(), - 'messageFormatter' => new MessageFormatter(), -]; -$openstack = new OpenCloud\OpenCloud(Utils::getAuthOpts($options)); -EOL; - } elseif ($this->verbosity === 2) { - $subst = <<<'EOL' -use OpenCloud\Integration\DefaultLogger; -use OpenCloud\Integration\Utils; -use GuzzleHttp\MessageFormatter; - -$options = [ - 'debugLog' => true, - 'logger' => new DefaultLogger(), - 'messageFormatter' => new MessageFormatter(MessageFormatter::DEBUG), -]; -$openstack = new OpenCloud\OpenCloud(Utils::getAuthOpts($options)); -EOL; - } else { - $subst = <<<'EOL' -use OpenCloud\Integration\Utils; - -$openstack = new OpenCloud\OpenCloud(Utils::getAuthOpts()); -EOL; - } - - return $subst; - } - - public function write($path, array $replacements) - { - $replacements = array_merge($this->getGlobalReplacements(), $replacements); - - $sampleFile = rtrim($this->basePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $path; - - if (!file_exists($sampleFile) || !is_readable($sampleFile)) { - throw new \RuntimeException(sprintf("%s either does not exist or is not readable", $sampleFile)); - } - - $content = strtr(file_get_contents($sampleFile), $replacements); - $content = str_replace("'vendor/'", "'" . dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . "vendor'", $content); - - $subst = $this->getConnectionTemplate(); - $content = preg_replace('/\([^)]+\)/', '', $content, 1); - $content = str_replace('$openstack = new OpenCloud\OpenCloud;', $subst, $content); - - $tmp = tempnam(sys_get_temp_dir(), 'openstack'); - file_put_contents($tmp, $content); - - $this->paths[] = $tmp; - - return $tmp; - } -} |
