コード例 #1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     printf("Getting tenant");
     $tenantResource = new TenantResource();
     $tenantPromise = $tenantResource->getTenantAsync($this->tenantId);
     $tenantPromise->then(function ($mozuResult) {
         $apiContext = new ApiContext($mozuResult->json());
         $this->object = new ProductResource($apiContext, DataViewMode::LIVE);
     }, function ($apiException) {
         parent::printError($apiException);
         throw $apiException;
     });
     $tenantPromise->wait();
 }
コード例 #2
0
 public function testGetTenantAsync()
 {
     try {
         $promise = $this->object->getTenantAsync($this->tenantId);
         $tenant = $promise->wait()->json();
         $this->assertSame($tenant->id, $this->tenantId);
     } catch (Exception $e) {
         parent::printError($e);
         $this->fail($e->getMessage());
     }
     /*$promise->then(function($mozuResult) {
           $tenant = $mozuResult->json();
           printf("TenantId : ". $tenant->id);
           $this->assertSame($tenant->id, $this->tenantId);
       }, function($e) {
           parent::printError($e);
           $this->fail($e->getMessage());
       });
       $promise->wait();*/
 }
コード例 #3
0
 private static function getAuthUrl($tenantId)
 {
     $tenantResource = new TenantResource();
     $mozuResult = $tenantResource->GetTenantAsync($tenantId)->wait();
     return HttpHelper::getUrl($mozuResult->json()->domain);
 }
コード例 #4
0
ファイル: MozuClient.php プロジェクト: sgorman/mozu-php-sdk
 private function validateContext()
 {
     if ($this->mozuUrl->getLocation() == UrlLocation::TENANT_POD) {
         if ($this->apiContext->getTenantId() < 0) {
             throw new \Exception("TenantId is missing");
         }
         if (trim($this->apiContext->getTenantUrl()) == "") {
             $tenantResource = new TenantResource(new ApiContext());
             $tenant = $tenantResource->getTenant($this->apiContext->getTenantId());
             if ($tenant == null) {
                 throw new \Exception("Tenant " . $this->apiContext->getTenantId() . " Not found");
             }
             $this->baseAddress = HttpHelper::getUrl($tenant->domain);
         } else {
             $this->baseAddress = HttpHelper::getUrl($this->apiContext->getTenantUrl());
         }
     } else {
         if ($this->mozuUrl->getLocation() == UrlLocation::PCI_POD) {
             if ($this->apiContext->getTenantId() < 0) {
                 throw new \Exception("TenantId is missing");
             }
             if (!isset(MozuConfig::$basePciUrl)) {
                 throw new \Exception("MozuConfig basePciUrl is empty. A valid value is required");
             }
             $this->baseAddress = MozuConfig::$basePciUrl;
         } else {
             $authentication = AppAuthenticator::getInstance();
             if ($authentication == null) {
                 throw new \Exception("App is not initialized. Use AppAuthenticator to initialize the app.");
             }
             if (!isset(MozuConfig::$baseAppAuthUrl)) {
                 throw new \Exception("MozuConfig baseAppAuthUrl is empty. A valid value is required");
             }
             $this->baseAddress = MozuConfig::$baseAppAuthUrl;
         }
     }
 }
コード例 #5
0
 private function getTenant()
 {
     $tenantResource = new TenantResource();
     $tenant = $tenantResource->getTenantAsync($this->apiContext->getTenantId())->wait();
     if ($tenant == null) {
         throw new \Exception("Tenant " . $this->apiContext->getTenantId() . " Not found");
     }
     return $tenant->json();
 }