PHPCI/Plugin/XMPP.php : Add test on empty recipients list and add test to check that all command was successful

This commit is contained in:
Alexandre Russo 2014-05-21 11:08:45 +02:00
parent 9deb00a096
commit 97d6a6030b

View file

@ -151,6 +151,13 @@ class XMPP implements \PHPCI\Plugin
return false;
}
/*
* Without recipients we can't send notification
*/
if (count($this->recipients) == 0) {
return false;
}
/*
* Try to build conf file
*/
@ -181,13 +188,16 @@ class XMPP implements \PHPCI\Plugin
/*
* Send XMPP notification for all recipients
*/
$success = false;
$success = array()
foreach($this->recipients as $recipient) {
$success = $this->phpci->executeCommand('echo %s | ' . $sendxmpp .
' %s %s', $message, $tls, $recipients);
if($cmd = $this->phpci->executeCommand('echo %s | ' . $sendxmpp .
' %s %s', $message, $tls, $recipients)) {
$success[] = $cmd;
}
print $this->phpci->getLastOutput();
}
return $success;
return (count($success) === count($this->recipients));
}
}