Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
refactor(Projects): remove Projects app
Browse files Browse the repository at this point in the history
- also removes testSaveContactWithAreaLockedRelation
 because it does not work correctly any more
 (AREA LOCKED app is not unlocked!)
  • Loading branch information
pschuele committed Jul 20, 2021
1 parent 36a3089 commit ba1f561
Show file tree
Hide file tree
Showing 85 changed files with 12 additions and 13,621 deletions.
29 changes: 12 additions & 17 deletions tests/setup/Setup/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public function testGetBackupStructureOnlyTables()

public function testSortInstallableApplications()
{
$apps = ['Tinebase','Addressbook','Courses','CoreData','Voipmanager','Filemanager','SimpleFAQ','HumanResources','Crm','Inventory','ExampleApplication','ActiveSync','Phone','Timetracker','Tasks','Projects','Felamimail','Admin','Calendar','Sales'];
$apps = ['Tinebase','Addressbook','Courses','CoreData','Voipmanager','Filemanager','SimpleFAQ','HumanResources','Crm','Inventory','ExampleApplication','ActiveSync','Phone','Timetracker','Tasks','Felamimail','Admin','Calendar','Sales'];

$applications = array();
foreach ($apps as $applicationName) {
Expand All @@ -452,17 +452,16 @@ public function testSortInstallableApplications()
6 => 'Sales',
7 => 'ExampleApplication',
8 => 'Inventory',
9 => 'Projects',
10 => 'Timetracker',
11 => 'ActiveSync',
12 => 'Filemanager',
13 => 'Phone',
14 => 'Crm',
15 => 'Tasks',
16 => 'Courses',
17 => 'Voipmanager',
18 => 'HumanResources',
19 => 'SimpleFAQ',
9 => 'Timetracker',
10 => 'ActiveSync',
11 => 'Filemanager',
12 => 'Phone',
13 => 'Crm',
14 => 'Tasks',
15 => 'Courses',
16 => 'Voipmanager',
17 => 'HumanResources',
18 => 'SimpleFAQ',
);
self::assertEquals($expected, array_keys($result));
}
Expand All @@ -471,11 +470,7 @@ public function testApplicationUpdateInitialize()
{
$appCtrl = Tinebase_Application::getInstance();

//try {
$exampleApp = $appCtrl->getApplicationByName(ExampleApplication_Config::APP_NAME);
/*} catch (Tinebase_Exception_NotFound $tenf) {
install it on the fly?
}*/
$exampleApp = $appCtrl->getApplicationByName(ExampleApplication_Config::APP_NAME);

$state = json_decode($appCtrl->getApplicationState($exampleApp, Tinebase_Application::STATE_UPDATES), true);
static::assertTrue(is_array($state) && isset($state[ExampleApplication_Setup_Update_0::RELEASE000_UPDATE001])
Expand Down
158 changes: 0 additions & 158 deletions tests/tine20/Addressbook/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1492,128 +1492,6 @@ public function testImportTagWithLongName()
$this->assertEquals(1, count($tags), 'tag not found');
$this->assertEquals(2, $tags->getFirstRecord()->occurrence);
}

/**
* test project relation filter
*
* @return array
*/
public function testProjectRelationFilter()
{
if (! Setup_Controller::getInstance()->isInstalled('Projects')) {
$this->markTestSkipped('Projects not installed.');
}

$contact = $this->_uit->saveContact($this->_getContactData());
$project = $this->_getProjectData($contact);

$projectJson = new Projects_Frontend_Json();
$newProject = $projectJson->saveProject($project);

$this->_testProjectRelationFilter($contact, 'definedBy', $newProject);
$this->_testProjectRelationFilter($contact, 'in', $newProject);
$this->_testProjectRelationFilter($contact, 'equals', $newProject);

return $contact;
}

/**
* get Project (create and link project + contacts)
*
* @return array
*/
protected function _getProjectData($_contact)
{
$project = array(
'title' => Tinebase_Record_Abstract::generateUID(),
'description' => 'blabla',
'status' => 'IN-PROCESS',
);

$project['relations'] = array(
array(
'own_model' => 'Projects_Model_Project',
'own_backend' => 'Sql',
'own_id' => 0,
'related_degree' => Tinebase_Model_Relation::DEGREE_SIBLING,
'type' => 'COWORKER',
'related_backend' => 'Sql',
'related_id' => $_contact['id'],
'related_model' => 'Addressbook_Model_Contact',
'remark' => NULL,
),
array(
'own_model' => 'Projects_Model_Project',
'own_backend' => 'Sql',
'own_id' => 0,
'related_degree' => Tinebase_Model_Relation::DEGREE_SIBLING,
'type' => 'RESPONSIBLE',
'related_backend' => 'Sql',
'related_id' => Tinebase_Core::getUser()->contact_id,
'related_model' => 'Addressbook_Model_Contact',
'remark' => NULL,
)

);

return $project;
}

/**
* helper for project relation filter test
*
* @param array $_contact
* @param string
* @param array $_project
*/
protected function _testProjectRelationFilter($_contact, $_operator, $_project)
{
switch ($_operator) {
case 'definedBy':
$closedStatus = Projects_Config::getInstance()->get(Projects_Config::PROJECT_STATUS)->records->filter('is_open', 0);
$filters = array(
array('field' => ":relation_type", "operator" => "equals", "value" => "COWORKER"),
array('field' => "status", "operator" => "notin", "value" => $closedStatus->getId()),
array('field' => 'id', 'operator' =>'in', 'value' => array($_project['id']))
);
break;
case 'in':
$filters = array(array('field' => 'id', 'operator' => $_operator, 'value' => array($_project['id'])));
break;
case 'equals':
$filters = array(array('field' => 'id', 'operator' => $_operator, 'value' => $_project['id']));
break;
}

$filterId = Tinebase_Record_Abstract::generateUID();
$filter = array(
array(
'field' => 'foreignRecord',
'operator' => 'AND',
'id' => $filterId,
'value' => array(
'linkType' => 'relation',
'appName' => 'Projects',
'modelName' => 'Project',
'filters' => $filters
)
),
array('field' => 'id', 'operator' => 'in', 'value' => array($_contact['id'], Tinebase_Core::getUser()->contact_id)),
);
$result = $this->_uit->searchContacts($filter, array());

$this->assertEquals('relation', $result['filter'][0]['value']['linkType']);
$this->assertTrue(isset($result['filter'][0]['id']), 'id expected');
$this->assertEquals($filterId, $result['filter'][0]['id']);

if ($_operator === 'definedBy') {
$this->assertEquals(':relation_type', $result['filter'][0]['value']['filters'][0]['field']);
$this->assertEquals(1, $result['totalcount'], 'Should find only the COWORKER!');
$this->assertEquals($_contact['org_name'], $result['results'][0]['org_name']);
} else {
$this->assertEquals(2, $result['totalcount'], 'Should find both contacts!');
}
}

/**
* testAttenderForeignIdFilter
Expand Down Expand Up @@ -2637,42 +2515,6 @@ public function testSearchEmailAddresssWithMailinglist()
. print_r($listaccounts, true));
}

/**
* testSaveContactWithAreaLockedRelation
*/
public function testSaveContactWithAreaLockedRelation()
{
// create contact with project relation
$contact = $this->testProjectRelationFilter();

// lock projects
$this->_createAreaLockConfig([
Tinebase_Model_AreaLockConfig::FLD_AREAS => ['Projects']
]);

Projects_Controller_Project::getInstance()->resetValidatedAreaLock();

// fetch & save contact again
$contactWithLockedProject = $this->_uit->getContact($contact['id']);
self::assertEquals(1, count($contactWithLockedProject['relations']));
self::assertFalse(isset($contactWithLockedProject['relations'][0]['related_record']));
self::assertEquals(Tinebase_Model_Relation::REMOVED_BY_AREA_LOCK,
$contactWithLockedProject['relations'][0]['record_removed_reason']);
$contactWithLockedProjectSaved = $this->_uit->saveContact($contactWithLockedProject);
self::assertEquals(1, count($contactWithLockedProjectSaved['relations']));

// unlock projects
$user = Tinebase_Core::getUser();
$this->_setPin();
Tinebase_AreaLock::getInstance()->unlock('login', 'userpin', '1234', $user);

// save contact again
$contactWithUnlockedProjectSaved = $this->_uit->saveContact($contactWithLockedProjectSaved);
self::assertEquals(1, count($contactWithUnlockedProjectSaved['relations']),'project relation should not be removed!');
self::assertTrue(isset($contactWithUnlockedProjectSaved['relations'][0]['related_record']));
self::assertEquals('blabla', $contactWithUnlockedProjectSaved['relations'][0]['related_record']['description']);
}

public function testSetImage()
{
$contact = $this->_getContactWithImage();
Expand Down
1 change: 0 additions & 1 deletion tests/tine20/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public static function suite()
'Courses',
'ActiveSync',
'Filemanager',
'Projects',
'HumanResources',
'Inventory',
'ExampleApplication',
Expand Down
29 changes: 0 additions & 29 deletions tests/tine20/Projects/AllTests.php

This file was deleted.

0 comments on commit ba1f561

Please sign in to comment.