diff --git a/tests/tine20/Tinebase/Frontend/JsonTest.php b/tests/tine20/Tinebase/Frontend/JsonTest.php index d302b73d0ab..ad8710f8994 100644 --- a/tests/tine20/Tinebase/Frontend/JsonTest.php +++ b/tests/tine20/Tinebase/Frontend/JsonTest.php @@ -775,8 +775,6 @@ protected function _assertImportExportDefinitions($registryData) */ public function testGetAllPersistentFilters() { - $this->markTestSkipped('@see 0010192: fix persistent filter tests'); - $registryData = $this->_instance->getAllRegistryData(); $filterData = $registryData['Tinebase']['persistentFilters']; @@ -788,6 +786,38 @@ public function testGetAllPersistentFilters() // check if accounts are resolved $this->assertTrue(is_array($grants[0]['account_name']), 'account should be resolved: ' . print_r($grants[0], true)); } + + public function testGetAllPersistentFiltersAfterRenameUser() { + + $userToCreate = TestCase::getTestUser([ + 'accountLoginName' => 'phpunitadminjson', + 'accountEmailAddress' => 'phpunitadminjson@' . TestServer::getPrimaryMailDomain(), + ]); + $userToCreate->smtpUser = new Tinebase_Model_EmailUser(array( + 'emailAddress' => $userToCreate->accountEmailAddress, + )); + $pw = Tinebase_Record_Abstract::generateUID(12); + $user = Admin_Controller_User::getInstance()->create($userToCreate, $pw, $pw); + + $filter = new Tinebase_Model_PersistentFilter([ + 'name' => 'PHPUnit testFilter', + 'description' => 'a test filter created by PHPUnit', + 'account_id' => null, + 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Filemanager')->getId(), + 'model' => 'Filemanager_Model_NodeFilter', + 'filters' => [ + ['field' => 'path', 'operator' => 'equals', 'value' => '/personal/phpunitadminjson/'] + ]]); + $newFilter = Tinebase_PersistentFilter::getInstance()->create($filter); + + $user['accountLoginName'] = 'phpunitadminjsonTest'; + Admin_Controller_User::getInstance()->update($user); + + $registryData = $this->_instance->getAllRegistryData(); + + $filterData = $registryData['Tinebase']['persistentFilters']; + self::assertNotEmpty($filterData, 'persistent filters can not loaded in the store'); + } /** * testGetUserProfile diff --git a/tine20/Tinebase/Model/Tree/Node/PathFilter.php b/tine20/Tinebase/Model/Tree/Node/PathFilter.php index 4cb1d7ea8d2..554e3edced5 100644 --- a/tine20/Tinebase/Model/Tree/Node/PathFilter.php +++ b/tine20/Tinebase/Model/Tree/Node/PathFilter.php @@ -67,15 +67,23 @@ public function setValue($_value) /** * returns array with the filter settings of this filter * - * @param bool $_valueToJson resolve value for json api? + * @param bool $_valueToJson resolve value for json api? * @return array + * @throws Tinebase_Exception_Record_DefinitionFailure + * @throws Tinebase_Exception_Record_Validation */ public function toArray($_valueToJson = false) { $result = parent::toArray($_valueToJson); if (! $this->_path && '/' !== $this->_value) { - $this->_path = Tinebase_Model_Tree_Node_Path::createFromPath($this->_value); + try { + $this->_path = Tinebase_Model_Tree_Node_Path::createFromPath($this->_value); + } catch (Tinebase_Exception_NotFound $tenf) { + if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ + . ' ' . $tenf->getMessage()); + return $result; + } } if ('/' === $this->_value || $this->_path->containerType === Tinebase_Model_Tree_Node_Path::TYPE_ROOT) { @@ -105,6 +113,8 @@ public function toArray($_valueToJson = false) $result['value']['path'] = $nodePath; } } catch (Exception $e) { + if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ + . ' ' . $e->getMessage()); $result['value'] = $node->toArray(); } diff --git a/tine20/Tinebase/Record/RecordSet.php b/tine20/Tinebase/Record/RecordSet.php index 4ecedf1c854..600045cdfd7 100644 --- a/tine20/Tinebase/Record/RecordSet.php +++ b/tine20/Tinebase/Record/RecordSet.php @@ -242,7 +242,7 @@ public function getValidationErrors() public function toArray() { $resultArray = array(); - foreach($this->_listOfRecords as $index => $record) { + foreach ($this->_listOfRecords as $index => $record) { $resultArray[$index] = $record->toArray(); }