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();*/ }
/** * 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(); }
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(); }