From 921c531a2922b2b58b13154cc50615dd58b59b22 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 7 Jan 2013 10:10:29 -0500 Subject: [PATCH] #4 make sure object storage newFromIdentity worked for multiple regions. --- src/HPCloud/Storage/ObjectStorage.php | 2 +- test/Tests/ObjectStorageTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/HPCloud/Storage/ObjectStorage.php b/src/HPCloud/Storage/ObjectStorage.php index ad8e30e..b447403 100644 --- a/src/HPCloud/Storage/ObjectStorage.php +++ b/src/HPCloud/Storage/ObjectStorage.php @@ -181,7 +181,7 @@ class ObjectStorage { public static function newFromIdentity($identity, $region = ObjectStorage::DEFAULT_REGION) { $cat = $identity->serviceCatalog(); $tok = $identity->token(); - return self::newFromServiceCatalog($cat, $tok); + return self::newFromServiceCatalog($cat, $tok, $region); } /** diff --git a/test/Tests/ObjectStorageTest.php b/test/Tests/ObjectStorageTest.php index 9bb993e..39844fa 100644 --- a/test/Tests/ObjectStorageTest.php +++ b/test/Tests/ObjectStorageTest.php @@ -100,6 +100,17 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase { $this->assertTrue(strlen($ostore->token()) > 0); } + public function testNewFromIdentityAltRegion() { + $ident = $this->identity(); + $ostore = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident, 'region-b.geo-1'); + $this->assertInstanceOf('\HPCloud\Storage\ObjectStorage', $ostore); + $this->assertTrue(strlen($ostore->token()) > 0); + + // Make sure the store is not the same as the default region. + $ostoreDefault = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident); + $this->assertNotEquals($ostore, $ostoreDefault); + } + /** * @group auth * @ group acl