This commit is contained in:
manzerbredes 2016-03-28 12:17:43 +02:00
commit 53f65de9d4
88 changed files with 3596 additions and 694 deletions

View file

@ -1,6 +1,6 @@
<?php
namespace OpenCloud\integration;
namespace OpenCloud\Integration;
use Psr\Log\AbstractLogger;

View file

@ -1,16 +1,19 @@
<?php
namespace OpenCloud\integration;
namespace OpenCloud\Integration;
class Runner
{
private $basePath;
private $logger;
private $services = [];
private $namespace;
public function __construct($basePath)
public function __construct($basePath, $testNamespace)
{
$this->basePath = $basePath;
$this->namespace = $testNamespace;
$this->logger = new DefaultLogger();
$this->assembleServicesFromSamples();
}
@ -73,15 +76,14 @@ class Runner
*/
private function getTest($serviceName, $version, $verbosity)
{
$namespace = (new \ReflectionClass($this))->getNamespaceName();
$className = sprintf("%s\\%s\\%sTest", $namespace, Utils::toCamelCase($serviceName), ucfirst($version));
$className = sprintf("%s\\%s\\%sTest", $this->namespace, Utils::toCamelCase($serviceName), ucfirst($version));
if (!class_exists($className)) {
throw new \RuntimeException(sprintf("%s does not exist", $className));
}
$basePath = $this->basePath . DIRECTORY_SEPARATOR . $serviceName . DIRECTORY_SEPARATOR . $version;
$smClass = sprintf("%s\\SampleManager", $namespace);
$smClass = sprintf("%s\\SampleManager", $this->namespace);
$class = new $className($this->logger, new $smClass($basePath, $verbosity));
if (!($class instanceof TestInterface)) {

View file

@ -1,6 +1,6 @@
<?php
namespace OpenCloud\integration;
namespace OpenCloud\Integration;
interface SampleManagerInterface
{

View file

@ -1,6 +1,6 @@
<?php
namespace OpenCloud\integration;
namespace OpenCloud\Integration;
use Psr\Log\LoggerInterface;

View file

@ -1,6 +1,6 @@
<?php
namespace OpenCloud\integration;
namespace OpenCloud\Integration;
use Psr\Log\LoggerInterface;

View file

@ -1,57 +1,11 @@
<?php
namespace OpenCloud\integration;
namespace OpenCloud\Integration;
use GuzzleHttp\Client;
use OpenCloud\Identity\v2\Api;
use OpenCloud\Identity\v2\Service;
use OpenCloud\Common\Transport\HandlerStack;
use OpenCloud\Common\Transport\Utils as CommonUtils;
class Utils
{
public static function getAuthOptsV3()
{
return [
'authUrl' => getenv('OS_AUTH_URL'),
'region' => getenv('OS_REGION_NAME'),
'user' => [
'id' => getenv('OS_USER_ID'),
'password' => getenv('OS_PASSWORD'),
],
'scope' => [
'project' => [
'id' => getenv('OS_PROJECT_ID'),
]
]
];
}
public static function getAuthOptsV2()
{
$httpClient = new Client([
'base_uri' => CommonUtils::normalizeUrl(getenv('OS_AUTH_URL')),
'handler' => HandlerStack::create(),
]);
return [
'authUrl' => getenv('OS_AUTH_URL'),
'region' => getenv('OS_REGION_NAME'),
'username' => getenv('OS_USERNAME'),
'password' => getenv('OS_PASSWORD'),
'tenantName' => getenv('OS_TENANT_NAME'),
'identityService' => new Service($httpClient, new Api),
];
}
public static function getAuthOpts(array $options = [])
{
$authOptions = getenv('OS_IDENTITY_API_VERSION') == '2.0'
? self::getAuthOptsV2()
: self::getAuthOptsV3();
return array_merge($authOptions, $options);
}
public static function toCamelCase($word, $separator = '_')
{
return str_replace($separator, '', ucwords($word, $separator));

View file

@ -1,10 +0,0 @@
<?php
$rootDir = dirname(dirname(__DIR__));
require_once $rootDir . '/vendor/autoload.php';
$basePath = $rootDir . '/samples';
$runner = new \OpenCloud\Integration\Runner($basePath);
$runner->runServices();