public function testExportOrgData()
 {
     $org = new Organization\OrgServiceProviderModel($this->_data);
     $array = $org->exportData();
     $this->assertTrue(is_array($array));
     $this->assertEquals($this->_data, $array);
 }
 public function testFindAllByParentId()
 {
     //TODO: @alfred dice que lo arregla, lo curioso es que si ejecutas el
     //test solo funciona, si ejecutas todos da un error de permisos
     $this->markTestIncomplete();
     $masterData = array('name' => 'ORG_TEST_PARENT1' . microtime(true), 'description' => "Description", 'status' => OrgMasterModel::ORG_STATUS_ACTIVATED, 'defaultLanguage' => "es", 'type' => OrgMasterModel::ORG_TYPE, 'primaryContact' => array('firstName' => 'pcfn', 'lastName' => 'pcln', 'phone' => '933453212', 'email' => '*****@*****.**', 'mobile' => '665348765', 'fax' => '933453232'), 'companyAddress' => array('line1' => 'line1', 'line2' => 'line2', 'city' => 'Barcelona', 'state' => 'Catalunya', 'region' => 'Barcelona', 'country' => 'ES', 'postalCode' => '08005'));
     $masters = array(new OrgMasterModel($masterData), new OrgMasterModel(array('name' => 'ORG_TEST_PARENT2' . microtime(true)) + $masterData));
     foreach ($masters as $parent) {
         $parent->save();
     }
     $childData = $this->_model->exportData();
     if (isset($childData['id'])) {
         unset($childData['id']);
     }
     $parentId = $masters[0]->getId();
     //         $this->_addUser(OrganizationMapper::cleanOrgId($parentId), OrgMasterModel::ORG_TYPE);
     $childData['parentId'] = $parentId;
     for ($i = 0; $i < 3; $i++) {
         $childData['name'] = 'child' . $i . 'ofParent1' . microtime(true);
         $childData['commercialName'] = 'child' . $i . 'ofParent1-' . microtime(true);
         $child = new OrgServiceProviderModel($childData);
         $child->save();
     }
     $filterList = \Application\Service\OrgService::getInstance()->buildFilterList(array('parentId' => $parentId, 'type' => OrgServiceProviderModel::ORG_TYPE));
     $childsParent1 = $this->_mapper->findAll(array('filterList' => $filterList))->getItems();
     $this->assertTrue(is_array($childsParent1));
     $this->assertEquals(3, count($childsParent1));
     $parentId = $masters[1]->getId();
     $this->_addUser(OrganizationMapper::cleanOrgId($parentId), OrgMasterModel::ORG_TYPE);
     $childData['parentId'] = $parentId;
     for ($i = 0; $i < 5; $i++) {
         $childData['name'] = 'child' . $i . 'ofParent2' . microtime(true);
         $childData['commercialName'] = 'child' . $i . 'ofParent2-' . microtime(true);
         $child = new OrgServiceProviderModel($childData);
         $child->save();
     }
     $filterList = Application\Service\OrgService::getInstance()->buildFilterList(array('parentId' => $parentId, 'type' => OrgServiceProviderModel::ORG_TYPE));
     $childsParent2 = $this->_mapper->findAll(array('filterList' => $filterList))->getItems();
     $this->assertTrue(is_array($childsParent2));
     $this->assertEquals(5, count($childsParent2));
     $this->_addUser(OrganizationMapper::cleanOrgId($masters[0]), OrgMasterModel::ORG_TYPE);
     foreach ($childsParent1 as $child) {
         $child->delete();
     }
     $this->_addUser(OrganizationMapper::cleanOrgId($masters[1]), OrgMasterModel::ORG_TYPE);
     foreach ($childsParent2 as $child) {
         $child->delete();
     }
     foreach ($masters as $parent) {
         $parent->delete();
     }
 }