public function testExportOrgData()
 {
     $this->markTestIncomplete();
     $org = new Organization\OrgCustomerModel($this->_data);
     $array = $org->exportData(FALSE);
     $this->assertTrue(is_array($array));
     $this->assertEquals($this->_data, $array);
 }
 public function testDelete()
 {
     $this->_org->setParentId($this->_createTree());
     $this->_org->save();
     $this->_mapper->delete($this->_org->getId());
     $orgCustomer = $this->_mapper->findOneById($this->_org->getId());
     $this->assertNull($orgCustomer);
 }
 protected function _updateOrgBillingAccounts()
 {
     // Check permissions
     $this->_helper->allowed('update_field_defaultBillingAccount', $this->_org);
     $this->_helper->allowed('update_field_billingAccounts', $this->_org);
     $filterHelper = $this->_helper->getHelper('filterNotAllowedFilters');
     $filterHelper->setThrowExOnNotAllowed(true);
     $filterHelper->direct('update_field', $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);
 }
 /**
  * @expectedException Application\Exceptions\ValidateException
  */
 public function testOrgCustomerRemoveFail()
 {
     $org = new OrgCustomerModel($this->_data);
     if (!$org) {
         $org->save();
     }
     $result = $this->_service->delete($org);
 }
 /**
  * @param  Application\Model\SupplServicesModel $service
  * @return boolean
  */
 public function removeCustomer(SupplServicesModel $service, OrgCustomerModel $org)
 {
     if (!strlen((string) $service->getId())) {
         throw new AppEx\InvalidArgumentException("Supplementary Services does not have an Id");
     }
     if (!$org instanceof OrgCustomerModel) {
         throw new AppEx\InvalidArgumentException("Organization must be a customer.");
     }
     $orgId = $org->getId();
     if (!isset($orgId) && !strlen($orgId)) {
         throw new AppEx\InvalidArgumentException("Organization customer does not have an Id");
     }
     if ($service->getPublished() != \Application\Model\SupplServicesModel::STATUS_PUBLISHED) {
         throw new AppEx\InvalidArgumentException("Supplementary Services must be published to have customers");
     }
     if ($service->subscriptionCount) {
         throw new AppEx\InvalidArgumentException("Customer sims are using supplementary services");
     }
     $result = $this->getMapper()->removeCustomer($service->getId(), $org->getId());
     \App::audit('Removed customer ' . $org->getId() . ' from supplementary services with Id ' . $service->getId(), $service);
     return $result;
 }