diff --git a/src/Vies/HeartBeat.php b/src/Vies/HeartBeat.php index de0fcf8..2902f4b 100644 --- a/src/Vies/HeartBeat.php +++ b/src/Vies/HeartBeat.php @@ -28,7 +28,7 @@ */ class HeartBeat { - private const DEFAULT_TIMEOUT = 10; + public const DEFAULT_TIMEOUT = 10; /** * @var string The host you want to verify @@ -39,7 +39,7 @@ class HeartBeat */ protected $port; /** - * @var string The path to append + * @var ?string The path to append */ protected $path; @@ -63,7 +63,7 @@ class HeartBeat * @param int $port * @param int $timeout */ - public function __construct(?string $host = null, int $port = Vies::VIES_PORT, ?string $path = null, int $timeout = self::DEFAULT_TIMEOUT) + public function __construct(?string $host = null, int $port = Vies::VIES_PORT, int $timeout = self::DEFAULT_TIMEOUT, ?string $path = null) { if (null !== $host) { $this->setHost($host); @@ -98,18 +98,18 @@ public function setHost(string $host): self } /** - * @return string + * @return ?string */ - public function getPath(): string + public function getPath(): ?string { return $this->path; } /** - * @param string $path + * @param ?string $path * @return self */ - public function setPath(string $path): self + public function setPath(?string $path = null): self { $this->path = $path; diff --git a/src/Vies/Vies.php b/src/Vies/Vies.php index 529da43..85ba5f7 100644 --- a/src/Vies/Vies.php +++ b/src/Vies/Vies.php @@ -243,7 +243,7 @@ public function setOptions(array $options): self */ public function getHeartBeat(): HeartBeat { - $this->heartBeat = $this->heartBeat ?? new HeartBeat(self::VIES_DOMAIN, self::VIES_PORT, self::VIES_PATH); + $this->heartBeat = $this->heartBeat ?? new HeartBeat(self::VIES_DOMAIN, self::VIES_PORT, HeartBeat::DEFAULT_TIMEOUT, self::VIES_PATH); return $this->heartBeat; } diff --git a/tests/Vies/HeartBeatTest.php b/tests/Vies/HeartBeatTest.php index 2f9fc8a..48174bb 100644 --- a/tests/Vies/HeartBeatTest.php +++ b/tests/Vies/HeartBeatTest.php @@ -112,8 +112,9 @@ public function testVerifyServicesIsDown() public function socketProvider(): array { return [ - 'Non-existing socket on localhost' => ['127.0.0.1', -1, 10, false], - 'Socket 443 on ec.europe.eu' => [Vies::VIES_DOMAIN, Vies::VIES_PORT, 10, true], + 'Non-existing socket on localhost' => ['127.0.0.1', -1, 10, null, false], + 'Socket 443 on ec.europe.eu' => [Vies::VIES_DOMAIN, Vies::VIES_PORT, 10, null, false], + 'Socket 443 on ec.europe.eu'.Vies::VIES_PATH => [Vies::VIES_DOMAIN, Vies::VIES_PORT, 10, Vies::VIES_PATH, true], ]; } @@ -124,10 +125,10 @@ public function socketProvider(): array * @covers ::getSecuredResponse * @covers ::readContents */ - public function testIsAliveUsingSockets($host, $port, $timeout, $expectedResult) + public function testIsAliveUsingSockets($host, $port, $timeout, $path, $expectedResult) { HeartBeat::$testingEnabled = false; - $heartBeat = new HeartBeat($host, $port, $timeout); + $heartBeat = new HeartBeat($host, $port, $timeout, $path); $actualResult = $heartBeat->isAlive(); $this->assertSame($expectedResult, $actualResult); }