diff --git a/ChainHealthcheck.php b/ChainHealthcheck.php index c238b48..1ff9ca5 100644 --- a/ChainHealthcheck.php +++ b/ChainHealthcheck.php @@ -19,6 +19,9 @@ final class ChainHealthcheck implements Healthcheck public function __construct(array $healthchecks = []) { + if (count($healthchecks) === 0) { + throw new \InvalidArgumentException('ChainHealthcheck requires healthchecks collection to be non empty.'); + } array_map([$this, 'add'], $healthchecks); } diff --git a/tests/Units/ChainHealthcheck.php b/tests/Units/ChainHealthcheck.php index 473a95f..6c1656a 100644 --- a/tests/Units/ChainHealthcheck.php +++ b/tests/Units/ChainHealthcheck.php @@ -18,6 +18,16 @@ class ChainHealthcheck extends atoum { + public function test healthchecks should be non empty() + { + $this + ->exception(function () { + $this->newTestedInstance([]); + }) + ->hasMessage('ChainHealthcheck requires healthchecks collection to be non empty.') + ; + } + public function test first failure should stop chain() { $this