From 9a9629ed9dff64688e46699a14400599577c0164 Mon Sep 17 00:00:00 2001 From: Christof Damian Date: Tue, 5 Jan 2016 17:09:58 +0100 Subject: [PATCH] fix multiple statuses --- CHANGES.md | 4 ++++ src/PlusPull/GitHub/PullRequest.php | 8 +++++++- tests/PlusPull/GitHub/PullRequestTest.php | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a006d79..ff01ed7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,10 @@ CHANGES ======= +0.5.9 +----- +* fix bug with multiple statuses + 0.5.8 ----- * allow leading whitespace diff --git a/src/PlusPull/GitHub/PullRequest.php b/src/PlusPull/GitHub/PullRequest.php index 18e180f..626ffbd 100644 --- a/src/PlusPull/GitHub/PullRequest.php +++ b/src/PlusPull/GitHub/PullRequest.php @@ -64,10 +64,16 @@ public function getCommentValue($commentBody) public function checkStatuses() { - if (empty($this->statuses[0]['state'])) { + if (empty($this->statuses)) { return false; } + foreach ($this->statuses as $status) { + if (empty($status['state']) or $status['state']!='success') { + return false; + } + } + return $this->statuses[0]['state']=='success'; } diff --git a/tests/PlusPull/GitHub/PullRequestTest.php b/tests/PlusPull/GitHub/PullRequestTest.php index 8b8cfee..77ad156 100644 --- a/tests/PlusPull/GitHub/PullRequestTest.php +++ b/tests/PlusPull/GitHub/PullRequestTest.php @@ -215,6 +215,20 @@ public function checkStatusesProvider() 'statuses' => array(array('state' => 'error')), 'expected' => false, ), + 'both, first error' => array( + 'statuses' => array( + array('state' => 'error'), + array('state' => 'success'), + ), + 'expected' => false, + ), + 'both, first success' => array( + 'statuses' => array( + array('state' => 'success'), + array('state' => 'error'), + ), + 'expected' => false, + ), ); }