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()); }
public function testUpdateCommit() { $project = $this->getProject(); $storage = $this->getStorage(); $storage->initCommit($project, '7d78d5', 'fabien', new \DateTime(), 'foo'); $commit = new Commit($project, '7d78d5'); $commit->setOutput('foo'); $commit->setStatusCode('success'); $storage->updateCommit($commit); $this->assertEquals('foo', $commit->getOutput()); $this->assertEquals('success', $commit->getStatusCode()); $commit = $storage->getCommit($project, '7d78d5'); $this->assertNotNull($commit->getBuildDate()); }
public function testNotify() { $project = new Project('Twig'); $failedCommit = new Commit($project, '123456'); $failedCommit->setAuthor('Fabien'); $failedCommit->setMessage('Foo'); $successCommit = new Commit($project, '123455'); $successCommit->setAuthor('Fabien'); $successCommit->setMessage('Bar'); $successCommit->setStatusCode('success'); $baseNotifier = $this->getMock('Sismo\\Notifier\\Notifier'); $baseNotifier->expects($this->once())->method('notify')->will($this->returnValue('foo')); $notifier = new CrossFingerNotifier(array($baseNotifier)); //a failed commit should call notify on real notifier $this->assertTrue($notifier->notify($failedCommit)); $project->setCommits(array($successCommit)); //a success commit should not call notify on real notifier $this->assertFalse($notifier->notify($successCommit)); }
public function testNotify() { $project = new Project('Twig'); $successCommit = new Commit($project, '123455'); $successCommit->setAuthor('Fabien'); $successCommit->setMessage('Bar'); $successCommit->setStatusCode('success'); $failedCommit = new Commit($project, '123456'); $failedCommit->setAuthor('Fabien'); $failedCommit->setMessage('Foo'); $failedCommit->setStatusCode('failed'); $project->setCommits(array($failedCommit, $successCommit)); $logger = $this->getMock('Psr\\Log\\NullLogger'); $logger->expects($this->once())->method('info'); $logger->expects($this->once())->method('critical'); $notifier = new LoggerNotifier($logger); //notify success commit $notifier->notify($successCommit); //notify failed commit $notifier->notify($failedCommit); }
private function createCommit($project, $result) { $commit = new Commit($project, $result['sha']); $commit->setAuthor($result['author']); $commit->setMessage($result['message']); $commit->setDate(\DateTime::createFromFormat('Y-m-d H:i:s', $result['date'])); if ($result['build_date']) { $commit->setBuildDate(\DateTime::createFromFormat('Y-m-d H:i:s', $result['build_date'])); } $commit->setStatusCode($result['status']); $commit->setOutput($result['output']); return $commit; }