private function formatDate($dayOnly, $format) { $lang = new MockBaseLanguage(); $lang->setReturnValue('getText', $format); $firstOfDecember2011_12_01 = 1322752769; return DateHelper::formatForLanguage($lang, $firstOfDecember2011_12_01, $dayOnly); }
function getText($key1, $key2, $args = array()) { if ($key1 == 'plugin_agiledashboard' && $key2 == 'planning-allows-assignment') { return 'This planning allows assignment of ' . $args[0] . ' to ' . $args[1]; } return parent::getText($key1, $key2, $args); }
function testChangesetShouldUseUserLanguageInBuildMessage() { $GLOBALS['Language']->expectNever('getText'); $userLanguage = new MockBaseLanguage(); $userLanguage->expectAtLeastOnce('getText'); $user = new MockUser(); $user->setReturnValue('getPreference', 'text', array('user_tracker_mailformat')); $user->setReturnValue('getLanguage', $userLanguage); $changeset = $this->buildChangeSet($user); $messages = array(); $changeset->buildMessage($messages, true, $user, false); }
function testChangesetShouldUseUserLanguageInBuildMessage() { $GLOBALS['Language']->expectNever('getText'); $userLanguage = new MockBaseLanguage(); $userLanguage->expectAtLeastOnce('getText'); $user = mock('PFUser'); $user->setReturnValue('getPreference', 'text', array('user_tracker_mailformat')); $user->setReturnValue('getLanguage', $userLanguage); $changeset = $this->buildChangeSet($user); stub($changeset)->getUserFromRecipientName('user01')->returns($user); $config = stub('TrackerPluginConfig')->isTokenBasedEmailgatewayEnabled()->returns(true); stub($changeset)->getTrackerPluginConfig()->returns($config); $recipients = array('user01' => false); $changeset->buildOneMessageForMultipleRecipients($recipients, true); }
function testGetMessageForUserParentListened() { $language = new MockBaseLanguage(); $language->setReturnValue('getText', 'notif_modified_by', array('plugin_docman', 'notif_modified_by')); $language->setReturnValue('getText', 'notif_wiki_new_version', array('plugin_docman', 'notif_wiki_new_version', 'wiki')); $language->setReturnValue('getText', 'notif_something_happen', array('plugin_docman', 'notif_something_happen')); $language->setReturnValue('getText', 'notif_footer_message', array('plugin_docman', 'notif_footer_message')); $language->setReturnValue('getText', 'notif_footer_message_link', array('plugin_docman', 'notif_footer_message_link')); $notificationsManager = new Docman_NotificationsManager_TestVersion(); $notificationsManager->setReturnValue('_getLanguageForUser', $language); $notificationsManager->_url = 'http://www.example.com/plugins/docman/'; $user = new MockUser(); $user->setReturnValue('getRealName', 'John Doe'); $user->setReturnValue('getId', 2); $params['path'] = new MockDocman_Path(); $params['path']->setReturnValue('get', 'Folder1/Folder2/File'); $params['item'] = new MockDocman_Item(); $params['item']->setReturnValue('getId', 10); $parentItem = new MockDocman_Item(); $parentItem->setReturnValue('getId', 1); $notificationsManager->setReturnValue('getListeningUsers', array($user->getId() => $parentItem)); $params['wiki_page'] = 'wiki'; $params['url'] = 'http://www.example.com/plugins/docman/'; $message1 = "Folder1/Folder2/File notif_modified_by John Doe.\nhttp://www.example.com/plugins/docman/&action=details&id=10\n\n\n--------------------------------------------------------------------\nnotif_footer_message\nnotif_footer_message_link\nhttp://www.example.com/plugins/docman/&action=details§ion=notifications&id=1"; $message2 = "Folder1/Folder2/File notif_modified_by John Doe.\nhttp://www.example.com/plugins/docman/&action=details&id=10\n\n\n--------------------------------------------------------------------\nnotif_footer_message\nnotif_footer_message_link\nhttp://www.example.com/plugins/docman/&action=details§ion=notifications&id=1"; $message3 = "notif_wiki_new_version John Doe.\nhttp://www.example.com/plugins/docman/\n\n\n--------------------------------------------------------------------\nnotif_footer_message\nnotif_footer_message_link\nhttp://www.example.com/plugins/docman/&action=details§ion=notifications&id=1"; $message4 = "notif_something_happen\n\n--------------------------------------------------------------------\nnotif_footer_message\nnotif_footer_message_link\nhttp://www.example.com/plugins/docman/&action=details§ion=notifications&id=1"; $this->assertEqual($message1, $notificationsManager->_getMessageForUser($user, 'modified', $params)); $this->assertEqual($message2, $notificationsManager->_getMessageForUser($user, 'new_version', $params)); $this->assertEqual($message3, $notificationsManager->_getMessageForUser($user, 'new_wiki_version', $params)); $this->assertEqual($message4, $notificationsManager->_getMessageForUser($user, 'something happen', $params)); }