diff --git a/src/pchevrel/BzKarma/Scoring.php b/src/pchevrel/BzKarma/Scoring.php index f1b7afe..9663d81 100644 --- a/src/pchevrel/BzKarma/Scoring.php +++ b/src/pchevrel/BzKarma/Scoring.php @@ -140,8 +140,13 @@ class Scoring public function __construct(array $bugsDetails, int $release) { // Replace numeric keys by the real bug number - $bugsDetails = $bugsDetails['bugs']; - $this->bugsDetails = array_combine(array_column($bugsDetails, 'id'), $bugsDetails); + if (isset($bugsDetails['bugs'])) { + $bugsDetails = $bugsDetails['bugs']; + $this->bugsDetails = array_combine(array_column($bugsDetails, 'id'), $bugsDetails); + } else { + $this->bugsDetails = []; + } + $this->release = strval($release); $this->beta = strval($this->release + 1); $this->nightly = strval($this->release + 2); diff --git a/tests/Unit/BzKarma/ScoringTest.php b/tests/Unit/BzKarma/ScoringTest.php index 6843d77..74c9172 100644 --- a/tests/Unit/BzKarma/ScoringTest.php +++ b/tests/Unit/BzKarma/ScoringTest.php @@ -16,6 +16,10 @@ ->toBe('131'); expect($obj->nightly) ->toBe('132'); + + $obj = new Scoring([], 130); + expect($obj->bugsDetails) + ->toBe([]); }); test('Scoring->getBugScoreDetails()', function () use ($obj) {