public function testValidateOrgMasterExists()
 {
     $org = OrgModelFactory::factory($this->_masterData);
     $result = $this->_validator->isValid($org->getId());
     $this->assertFalse($result);
     $messages = $this->_validator->getMessages();
     $this->assertArrayHasKey(App_Validate_Ericsson_OrganizationNotExistsByName::ERROR_ORGANIZATION_NAME_FOUND, $messages);
 }
 public function testValidateOrgMasterExists()
 {
     $org = \Application\Model\OrgModelFactory::factory($this->_masterData);
     $org->save();
     $this->_orgIdToDelete = $org->getId();
     $result = $this->_validator->isValid($org->getId());
     $this->assertTrue($result);
 }
 public function testImportOrgData()
 {
     $org = new Organization\OrgMasterModel();
     $org->importData($this->_data);
     $this->assertNotNull($org, "Not null from import.");
     $this->checkModelAgainstStruct($org, 'import with importData');
     $this->assertInstanceOf('\\Application\\Model\\Organization\\OrgMasterModel', $org);
     // or
     $org = new Organization\OrgMasterModel($this->_data);
     $this->assertNotNull($org, "Not null from constructor.");
     $this->checkModelAgainstStruct($org, 'import with constructor');
     $this->assertInstanceOf('\\Application\\Model\\Organization\\OrgMasterModel', $org);
     // or
     $org = \Application\Model\OrgModelFactory::factory($this->_data);
     $this->assertNotNull($org, "Not null from factory.");
     $this->checkModelAgainstStruct($org, 'import with factory');
     $this->assertInstanceOf('\\Application\\Model\\Organization\\OrgMasterModel', $org);
 }
 public function testImportOrgData()
 {
     $this->markTestIncomplete();
     $org = new Organization\OrgCustomerModel();
     $org->importData($this->_data);
     $this->checkModelAgainstStruct($org, 'import with importData');
     $this->assertNotNull($org);
     $this->assertInstanceOf('\\Application\\Model\\Organization\\OrgCustomerModel', $org);
     // or
     $org = new Organization\OrgCustomerModel($this->_data);
     $this->checkModelAgainstStruct($org, 'import with constructor');
     $this->assertNotNull($org);
     $this->assertInstanceOf('\\Application\\Model\\Organization\\OrgCustomerModel', $org);
     // or
     $org = \Application\Model\OrgModelFactory::factory($this->_data);
     $this->checkModelAgainstStruct($org, 'import with factory');
     $this->assertNotNull($org);
     $this->assertInstanceOf('\\Application\\Model\\Organization\\OrgCustomerModel', $org);
 }
Ejemplo n.º 5
0
 /**
  * User dependencies injection
  */
 public static function initUserAccount()
 {
     $ident = \Zend_Auth::getInstance()->getIdentity();
     // Transaction injection
     \App::get("trackingtoken");
     ProtoAbstractMapper::$accountingTransactionPrefix = 'Testing-';
     // User injection
     ProtoAbstractMapper::$accountingUserId = $ident['id'];
     ProtoAbstractMapper::$language = 'en';
     $user = \App::getUserLogged(null, true);
     $allowed = Zend_Controller_Action_HelperBroker::getStaticHelper('allowed');
     $allowed->setUser($user);
     AbstractMapper::$organizationId = $user->organizationId;
     // Org injection
     if (!empty($ident['orgId'])) {
         $org = OrgService::getInstance()->load($ident['orgId']);
         if (!$org) {
             $org = OrgModelFactory::factory(array('id' => $ident['orgId'], 'type' => OrganizationMapper::getTypeByOrgId($ident['orgId'])));
         }
         \App::getOrgUserLogged($org);
         AbstractMapper::$organizationId = $ident['orgId'];
     }
     WatcherMapper::getInstance()->destroySingleton();
 }
Ejemplo n.º 6
0
 public function testValidateFail()
 {
     $data = array('name' => 'Customer name' . microtime(true), 'type' => OrgCustomerModel::ORG_TYPE, 'defaultLanguage' => 1, 'parentId' => $this->_provider->getId(), 'status' => OrgModelAbstract::ORG_STATUS_ACTIVATED, 'billingCycleStart' => array("dayOfMonth" => "13", "timezone" => "Europe/Madrid"), 'currency' => 1, 'companyType' => 1, 'sector' => 1, 'primaryContact' => array('firstName' => 'Pepe', 'lastName' => 'González', 'phone' => '934443344', 'email' => '*****@*****.**', 'mobile' => '655445533', 'fax' => '934443344'), "companyAddress" => array("line1" => "line1", "line2" => "line2", "city" => "Barcelona", "state" => "923458742", "country" => 1, "postalCode" => "08080"), 'billingContact' => array('firstName' => 'Pepe', 'lastName' => 'González', 'phone' => '934443344', 'email' => '*****@*****.**', 'mobile' => '655445533', 'fax' => '934443344'), 'defaultBillingAccount' => array("fiscalNumber" => "23hj5-84374", "address" => array("line1" => "line1", "line2" => "line2", "city" => "Barcelona", "state" => "923458742", "country" => 1, "postalCode" => "08080")), 'shippingAddress' => array('line1' => 'line1', 'line2' => 'line2', 'city' => 'Barcelona', 'state' => 'Catalonia', 'country' => 1, 'postalCode' => '08080'));
     $result = $this->_validateCollection->isValid(OrgModelFactory::factory($data));
     $this->assertFalse($result);
 }
Ejemplo n.º 7
0
 public function testValidateFail()
 {
     $data = array("name" => "FCB322" . microtime(true), "type" => "master", "parentId" => self::SUPER_ORG_ID, 'defaultLanguage' => '1', "primaryContact" => array("firstName" => "", "lastName" => "Guardiola", "phone" => "933458742", "email" => "*****@*****.**", "mobile" => "664559583", "fax" => "934568732"), "companyAddress" => array("line" => array("line 1", "line 2"), "city" => "Barcelona", "state" => "923458742", "region" => "Catalunya", "country" => 1, "postalCode" => "08080"));
     $result = $this->_validateCollection->isValid(\Application\Model\OrgModelFactory::factory($data));
     $this->assertFalse($result);
 }
 /**
  * Create a new organization
  */
 public function postAction()
 {
     // Avoid setting custom id
     $data = $this->_helper->requestData(true);
     $data = $this->_helper->filter($data)->blacklist(array('id', 'status'));
     $org = OrgModelFactory::factory($data);
     // Check if it's allowed
     $this->_helper->allowed('create', $org);
     // Create the organization via its service
     $this->_orgSrv->create($org);
     // Response with the organization id
     $this->view->data = $org->getId();
 }
Ejemplo n.º 9
0
 /**
  *
  * @param  string                 $fieldName
  * @param  OrgModelAbstract|array $fieldValue
  * @return self
  */
 protected function setOrg($fieldName, $fieldValue)
 {
     if (is_array($fieldValue)) {
         $fieldValue = OrgModelFactory::factory($fieldValue);
     }
     $this->_refData[$fieldName] = $fieldValue;
     // Update attributes
     $this->{$fieldName . 'Id'} = $fieldValue ? $fieldValue->getId() : null;
     $this->{$fieldName . 'Name'} = $fieldValue ? $fieldValue->getName() : null;
     return $this;
 }
 protected function _findOneById($id)
 {
     $methodName = static::$_protoMethods['findOneById'];
     $proto = $this->_createProto($methodName);
     $proto->setId(self::cleanOrgId($id));
     $response = $this->_sendRequest($methodName, array('protoMessage' => $proto));
     //TODO: remove this code when ericsson return an error if org doesn't exist
     //Workaround
     if ($response->getData() === null && $response->getResult()->getCode() == 0) {
         $response->getResult()->setCode(-1);
     }
     if ($this->_checkGetResponse($response)) {
         $data = $response->getData()->serialize(new \DrSlump\Protobuf\Codec\PhpArray());
         $data = $this->_mapEricssonModelToModel($data);
         return OrgModelFactory::factory($data + array('type' => static::$_organizationType));
     }
     return null;
 }