public function testUpdateOrg()
 {
     // First persist it
     $this->_org->save();
     // Update it
     $this->_org->getPrimaryContact()->setFirstName('EditedFoo');
     $this->_service->update($this->_org);
     // Load it again to compare
     $org = $this->_service->load($this->_org->getId());
     $this->assertEquals($this->_org->exportData(), $org->exportData());
 }
 public function testUpdateOrg()
 {
     $this->markTestIncomplete();
     // First persist it
     $this->_org->setParentId(self::MASTER_ORG_ID);
     $this->_org->save();
     // Update it
     $this->_org->setName('EditedFoo');
     $this->_service->update($this->_org);
     // Load it again to compare
     $org = $this->_service->load($this->_org->getId());
     $this->assertEquals($this->_org->exportData(), $org->exportData());
 }
 /**
  * Update an organization identified by its Id
  */
 public function putAction()
 {
     $data = $this->_helper->requestData(true);
     // Try to load the chosen organization
     $id = $this->getRequest()->getParam('id');
     $org = $this->_orgSrv->load($id);
     if (empty($org)) {
         throw new NotFoundException('Organization ' . $id . ' not found', 404);
     }
     // Check permissions
     try {
         $this->_helper->allowed('update', $org);
     } catch (ForbiddenException $e) {
         try {
             $billingAccountData = array();
             $this->_helper->allowed('update_field_defaultBillingAccount', $org);
             if (isset($data['defaultBillingAccount'])) {
                 $billingAccountData['defaultBillingAccount'] = $data['defaultBillingAccount'];
             }
             $this->_helper->allowed('update_field_billingAccounts', $org);
             if (isset($data['billingAccounts'])) {
                 $billingAccountData['billingAccounts'] = $data['billingAccounts'];
             }
             if (empty($billingAccountData)) {
                 throw $e;
             }
             $data = $billingAccountData;
         } catch (ForbiddenException $e2) {
             throw $e;
         }
     }
     $data = $this->_helper->filter($data)->blacklist(array('id', 'parentId', 'status'));
     $orgClass = get_class($org);
     $newOrg = new $orgClass($data);
     $newOrg->setParentId($org->getParentId());
     $newOrg->setStatus($org->getStatus());
     $this->_helper->filterNotAllowedFields('update_field', $org, $newOrg);
     // Fix customer
     if (isset($org->trialDuration)) {
         unset($org->trialDuration);
     }
     $newData = $newOrg->exportData();
     // Modify the current details with the new data
     if (!empty($newData)) {
         $org->importData($newData);
         $this->_orgSrv->update($org);
     }
     $this->view->data = $org->getId();
 }
 public function testUpdateOrg()
 {
     // First persist it
     $this->_org->setParentId(self::CUSTOMER_ORG_ID);
     $this->_org->save();
     // Update it
     $this->_org->setName('EditedFoo');
     $this->_org->otherContact_1 = array();
     $this->_service->update($this->_org);
     // Load it again to compare
     $org = $this->_service->load($this->_org->getId());
     $this->assertNull($org->otherContact_1, "Cleared other contact");
     unset($this->_org->otherContact_1);
     $this->assertEquals($this->_org->exportData(), $org->exportData());
 }
 protected function _updateOrgBillingAccounts()
 {
     // Check permissions
     $this->_helper->allowed('update_field_defaultBillingAccount', $this->_org);
     $this->_helper->allowed('update_field_billingAccounts', $this->_org);
     // Make a copy
     $billings = $this->_billings;
     // Set default one
     $default = array_shift($billings);
     $this->_org->setDefaultBillingAccount($default);
     //Workaround... ericsson fails them don't exist
     if (!$this->_org->getTaxes()) {
         $this->_org->setTaxes(array());
     }
     if (!$this->_org->getDiscounts()) {
         $this->_org->setDiscounts(array());
     }
     // Set other billings
     $this->_org->importData(array('billingAccounts' => $billings));
     return $this->_orgSrv->update($this->_org);
 }
Пример #6
0
 public function testCrud()
 {
     // Creare new org
     $org = new OrgCustomerModel($this->_data);
     try {
         $this->_service->create($org);
     } catch (ValidateException $e) {
         $this->fail("Fail creating org: " . var_export($e->getValidationErrors(), true));
     }
     try {
         // Update it (changeBillingCycleStartDay integration)
         $this->_service->update($org);
     } catch (ValidateException $e) {
         $this->fail("Fail updating org: " . var_export($e->getValidationErrors(), true));
     }
     try {
         // Remove it
         //             $this->_service->delete($org);
     } catch (ValidateException $e) {
         $this->fail("Fail deleting org: " . var_export($e->getValidationErrors(), true));
     }
 }