Esempio n. 1
0
 /**
  * Test the autoloader.
  */
 public function testAutoloader()
 {
     \HPCloud\Bootstrap::useAutoloader();
     // If we can construct a class, we are okay.
     $test = new \HPCloud\Exception("TEST");
     $this->assertInstanceOf('\\HPCloud\\Exception', $test);
 }
Esempio n. 2
0
 public static function setUpBeforeClass()
 {
     global $bootstrap_settings;
     if (!isset($bootstrap_settings)) {
         $bootstrap_settings = array();
     }
     self::$settings = $bootstrap_settings;
     //$this->setTestNamespace('Tests\Units');
     if (file_exists('test/settings.ini')) {
         self::$settings += parse_ini_file('test/settings.ini');
     } else {
         throw new \Exception('Could not access test/settings.ini');
     }
     \HPCloud\Bootstrap::useAutoloader();
     \HPCloud\Bootstrap::setConfiguration(self::$settings);
     //parent::__construct($score, $locale, $adapter);
 }
<?php

require_once __DIR__ . '/../src/HPCloud/Bootstrap.php';
use HPCloud\Bootstrap;
Bootstrap::useAutoloader();
Bootstrap::useStreamWrappers();
$ini = parse_ini_file(getenv('HOME') . '/.hpcloud.ini');
$settings = array('username' => $ini['username'], 'password' => $ini['password'], 'tenantid' => $ini['tenantId'], 'endpoint' => $ini['url']);
Bootstrap::setConfiguration($settings);
// Create a new file and write it to the object store.
$newfile = fopen('swift://Example/my_file.txt', 'w');
fwrite($newfile, "Good Morning!");
fclose($newfile);
// Check for an object:
if (file_exists('swift://Example/my_file.txt')) {
    print "Found my_file.txt." . PHP_EOL;
}
// Get an entire object at once:
$file = file_get_contents('swift://Example/my_file.txt');
print 'File: ' . $file . PHP_EOL;
$cxt = stream_context_create(array('swift' => array('account' => $ini['account'], 'key' => $ini['secret'], 'tenantid' => $ini['tenantId'], 'endpoint' => $ini['url'])));
print file_get_contents('swift://Example/my_file.txt', FALSE, $cxt);
Esempio n. 4
0
AUTHORS OR COPYRIGHT HOLDERS BE  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
============================================================================ */
/**
 * @file
 * A commandline demonstration of the PHP API.
 */
// Name of the container to test. It must have
// CDN enabled. Using the one you use for standard
// tests is ill advised.
define('TEST_CONTAINER', 'mycontainer');
$base = __DIR__ . '/../src';
require_once $base . '/HPCloud/Bootstrap.php';
\HPCloud\Bootstrap::useAutoloader();
$inifile = __DIR__ . '/settings.ini';
if (!is_readable($inifile)) {
    die('Could not find ' . $inifile);
}
$ini = parse_ini_file($inifile, FALSE);
\HPCloud\Bootstrap::setConfiguration($ini);
\HPCloud\Bootstrap::useStreamWrappers();
$id = new \HPCloud\Services\IdentityServices($ini['hpcloud.identity.url']);
//$token = $id->authenticateAsAccount($ini['hpcloud.identity.account'], $ini['hpcloud.identity.secret'], $ini['hpcloud.identity.tenantId']);
$token = $id->authenticateAsUser($ini['hpcloud.identity.username'], $ini['hpcloud.identity.password'], $ini['hpcloud.identity.tenantId']);
$objstore = \HPCloud\Storage\ObjectStorage::newFromServiceCatalog($id->serviceCatalog(), $token);
$cdn = \HPCloud\Storage\CDN::newFromServiceCatalog($id->serviceCatalog(), $token);
$objstore->useCDN($cdn);
//var_dump($cdn->containers());
// Check that the container has CDN.