function testSendNotificationsFirstIsFailure()
 {
     $feedback = new MockFeedback($this);
     // First message fail
     $mail1 = new MockMail($this);
     $mail1->setReturnValue('send', false);
     // Second succeed
     $mail2 = new MockMail($this);
     $mail2->setReturnValue('send', true);
     // Raises an error
     $feedback->expectOnce('log', array('warning', '*'));
     $project = new MockProject($this);
     $project->setReturnValue('getPublicName', 'Guinea Pig');
     $itemFty = new MockDocman_ItemFactory($this);
     $notifDao = new MockNotificationsDao($this);
     $nm = new Docman_NotificationsManager_TestVersion($this);
     $nm->setReturnValue('_getDao', $notifDao);
     $nm->setReturnValue('_getItemFactory', $itemFty);
     $nm->setReturnValue('_groupGetObject', $project);
     $nm->setReturnValueAt(0, '_getMail', $mail1);
     $nm->setReturnValueAt(1, '_getMail', $mail2);
     $nm->__construct(101, '/toto', $feedback);
     $user = new MockUser($this);
     $user->setReturnValue('getEmail', '*****@*****.**');
     $nm->_messages[] = array('title' => 'Move 1', 'content' => 'Changed 1', 'to' => array($user));
     $nm->_messages[] = array('title' => 'Move 2', 'content' => 'Changed 2', 'to' => array($user));
     $nm->sendNotifications('', '');
 }
 function testSendNotificationsSuccess()
 {
     $mail = new MockMail($this);
     $mail->setReturnValue('send', true);
     $feedback = new MockFeedback($this);
     $project = new MockProject($this);
     $project->setReturnValue('getPublicName', 'Guinea Pig');
     $itemFty = new MockDocman_ItemFactory($this);
     $notifDao = new MockNotificationsDao($this);
     $project = aMockProject()->withId(101)->build();
     $mail_builder = new MailBuilder(TemplateRendererFactory::build());
     $nm = new Docman_NotificationsManager_TestVersion($this);
     $nm->setReturnValue('_getDao', $notifDao);
     $nm->setReturnValue('_getItemFactory', $itemFty);
     $nm->setReturnValue('_groupGetObject', $project);
     $nm->__construct($project, '/toto', $feedback, $mail_builder);
     $user = mock('PFUser');
     $user->setReturnValue('getEmail', '*****@*****.**');
     $nm->_messages = array(array('title' => 'Move', 'content' => 'Changed', 'to' => array($user)));
     $nm->sendNotifications('', '');
 }