Imported code from old repository
This commit is contained in:
63
tests/OfflineTests/AccountGateway/AAUIDParserTest.php
Normal file
63
tests/OfflineTests/AccountGateway/AAUIDParserTest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
namespace CloudObjects\SDK\AccountGateway;
|
||||
|
||||
use ML\IRI\IRI;
|
||||
|
||||
class AAUIDParserTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testValidAccountAAUID() {
|
||||
$aauid = new IRI('aauid:abcd1234abcd1234');
|
||||
$this->assertEquals(AAUIDParser::AAUID_ACCOUNT, AAUIDParser::getType($aauid));
|
||||
$this->assertEquals('abcd1234abcd1234', AAUIDParser::getAAUID($aauid));
|
||||
}
|
||||
|
||||
public function testInvalidAccountAAUID() {
|
||||
$aauid = new IRI('aauid:abcd1234abcd123');
|
||||
$this->assertEquals(AAUIDParser::AAUID_INVALID, AAUIDParser::getType($aauid));
|
||||
$this->assertNull(AAUIDParser::getAAUID($aauid));
|
||||
}
|
||||
|
||||
public function testValidAccountConnectionAAUID() {
|
||||
$aauid = new IRI('aauid:abcd1234abcd1234:connection:AA');
|
||||
$this->assertEquals(AAUIDParser::AAUID_CONNECTION, AAUIDParser::getType($aauid));
|
||||
$this->assertEquals('abcd1234abcd1234', AAUIDParser::getAAUID($aauid));
|
||||
$this->assertEquals('AA', AAUIDParser::getQualifier($aauid));
|
||||
}
|
||||
|
||||
public function testInvalidAccountConnectionAAUID() {
|
||||
$aauid = new IRI('aauid:abcd1234abcd1234:connection:AAA');
|
||||
$this->assertEquals(AAUIDParser::AAUID_INVALID, AAUIDParser::getType($aauid));
|
||||
$this->assertNull(AAUIDParser::getAAUID($aauid));
|
||||
$this->assertNull(AAUIDParser::getQualifier($aauid));
|
||||
}
|
||||
|
||||
public function testValidConnectedAccountAAUID() {
|
||||
$aauid = new IRI('aauid:abcd1234abcd1234:account:AA');
|
||||
$this->assertEquals(AAUIDParser::AAUID_CONNECTED_ACCOUNT, AAUIDParser::getType($aauid));
|
||||
$this->assertEquals('abcd1234abcd1234', AAUIDParser::getAAUID($aauid));
|
||||
$this->assertEquals('AA', AAUIDParser::getQualifier($aauid));
|
||||
}
|
||||
|
||||
public function testInvalidConnectedAccountAAUID() {
|
||||
$aauid = new IRI('aauid:abcd1234abcd1234:account:X9');
|
||||
$this->assertEquals(AAUIDParser::AAUID_INVALID, AAUIDParser::getType($aauid));
|
||||
$this->assertNull(AAUIDParser::getAAUID($aauid));
|
||||
$this->assertNull(AAUIDParser::getQualifier($aauid));
|
||||
}
|
||||
|
||||
public function testFromStringValid() {
|
||||
$aauid1 = new IRI('aauid:5678defg8765gfed');
|
||||
$aauid2 = AAUIDParser::fromString('aauid:5678defg8765gfed');
|
||||
$this->assertEquals($aauid1, $aauid2);
|
||||
|
||||
$aauid1 = new IRI('aauid:5678defg8765gfed');
|
||||
$aauid2 = AAUIDParser::fromString('5678defg8765gfed');
|
||||
$this->assertEquals($aauid1, $aauid2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
namespace CloudObjects\SDK\AccountGateway;
|
||||
|
||||
use GuzzleHttp\Psr7\Request as GuzzlePsrRequest;
|
||||
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
|
||||
|
||||
class AccountContextParseTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testParsePsrRequest() {
|
||||
$request = new GuzzlePsrRequest('GET', '/', [
|
||||
'C-AAUID' => '1234123412341234', 'C-Access-Token' => 'test'
|
||||
]);
|
||||
|
||||
$context = AccountContext::fromPsrRequest($request);
|
||||
$this->assertNotNull($context);
|
||||
$this->assertEquals('1234123412341234', AAUIDParser::getAAUID($context->getAAUID()));
|
||||
}
|
||||
|
||||
public function testParseSymfonyRequest() {
|
||||
$request = SymfonyRequest::create('/', 'GET', [], [], [], [
|
||||
'HTTP_C_AAUID' => '1234123412341234', 'HTTP_C_ACCESS_TOKEN' => 'test'
|
||||
]);
|
||||
|
||||
$context = AccountContext::fromSymfonyRequest($request);
|
||||
$this->assertNotNull($context);
|
||||
$this->assertEquals('1234123412341234', AAUIDParser::getAAUID($context->getAAUID()));
|
||||
}
|
||||
|
||||
}
|
||||
33
tests/OfflineTests/AccountGateway/AccountContextTest.php
Normal file
33
tests/OfflineTests/AccountGateway/AccountContextTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
namespace CloudObjects\SDK\AccountGateway;
|
||||
|
||||
use ML\IRI\IRI;
|
||||
|
||||
class AccountContextTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
private $context;
|
||||
|
||||
protected function setUp() {
|
||||
$this->context = new AccountContext(new IRI('aauid:aaaabbbbccccdddd'), 'DUMMY');
|
||||
}
|
||||
|
||||
public function testDefaultGatewayBaseURL() {
|
||||
$this->assertEquals('https://aaaabbbbccccdddd.aauid.net', $this->context->getClient()->getConfig('base_uri'));
|
||||
}
|
||||
|
||||
public function testSetAccountGatewayBaseURLTemplateWithPlaceholder() {
|
||||
$this->context->setAccountGatewayBaseURLTemplate('http://{aauid}.localhost');
|
||||
$this->assertEquals('http://aaaabbbbccccdddd.localhost', $this->context->getClient()->getConfig('base_uri'));
|
||||
}
|
||||
|
||||
public function testSetAccountGatewayBaseURLTemplateWithoutPlaceholder() {
|
||||
$this->context->setAccountGatewayBaseURLTemplate('http://localhost');
|
||||
$this->assertEquals('http://localhost', $this->context->getClient()->getConfig('base_uri'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user