public function testIsSuccessful() { $commit = new Commit(new Project('Twig'), '7d78d5f7a8c039059046d6c5e1d7f66765bd91c7'); $this->assertFalse($commit->isSuccessful()); $commit->setStatusCode('failed'); $this->assertFalse($commit->isSuccessful()); $commit->setStatusCode('success'); $this->assertTrue($commit->isSuccessful()); }
/** * Determines if a build needs to be notify * based on his status and his predecessor's one * * @param Commit $commit The commit to analyse * @return Boolean whether the commit need notification or not */ protected function commitNeedNotification(Commit $commit) { if (!$commit->isSuccessful()) { return true; } //getProject()->getLatestCommit() actually contains the previous build $previousCommit = $commit->getProject()->getLatestCommit(); return !$previousCommit || $previousCommit->getStatusCode() != $commit->getStatusCode(); }
/** * Notify a project commit * * @param Sismo\Commit $commit The latest project commit * * @return bool TRUE on a succesfull notification, FALSE on failure */ public function notify(Commit $commit) { try { $this->growl->register(); $name = $commit->isSuccessful() ? self::NOTIFY_SUCCESS : self::NOTIFY_FAILURE; $notifications = $this->growl->getApplication()->getGrowlNotifications(); $this->growl->publish($name, $commit->getProject()->getName(), $this->format($this->format, $commit), $notifications[$name]); } catch (\Net_Growl_Exception $e) { return false; } return true; }
public function notify(Commit $commit) { $this->register(); return $this->doNotify($commit->isSuccessful() ? 'Success' : 'Fail', $commit->getProject()->getName(), $this->format($this->format, $commit)); }