Skip to content

Commit c81793c

Browse files
committed
more bugfixin'
1 parent e90719c commit c81793c

File tree

7 files changed

+73
-21
lines changed

7 files changed

+73
-21
lines changed

src/Coordinate/Coordinate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function DistanceTo(self $other): Time\Duration
165165
if ($adjustedDist > 0.0) {
166166
$dist = $adjustedDist;
167167
}
168-
return new Time\Duration($dist * $secondsToNanoseconds);
168+
return Time::Duration($dist * $secondsToNanoseconds);
169169
}
170170

171171
/**

src/Hydration.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ final class Hydration
5959

6060
public const OMITEMPTY_FIELD = [self::FIELD_OMITEMPTY => true];
6161

62-
public const OMITEMPTY_STRING_FIELD = [self::FIELD_TYPE => self::STRING] + self::OMITEMPTY_FIELD;
63-
public const OMITEMPTY_INTEGER_FIELD = [self::FIELD_TYPE => self::INTEGER] + self::OMITEMPTY_FIELD;
64-
public const OMITEMPTY_DOUBLE_FIELD = [self::FIELD_TYPE => self::DOUBLE] + self::OMITEMPTY_FIELD;
65-
public const OMITEMPTY_BOOLEAN_FIELD = [self::FIELD_TYPE => self::BOOLEAN] + self::OMITEMPTY_FIELD;
62+
public const OMITEMPTY_STRING_FIELD = [self::FIELD_TYPE => self::STRING] + self::OMITEMPTY_FIELD;
63+
public const OMITEMPTY_INTEGER_FIELD = [self::FIELD_TYPE => self::INTEGER] + self::OMITEMPTY_FIELD;
64+
public const OMITEMPTY_DOUBLE_FIELD = [self::FIELD_TYPE => self::DOUBLE] + self::OMITEMPTY_FIELD;
65+
public const OMITEMPTY_BOOLEAN_FIELD = [self::FIELD_TYPE => self::BOOLEAN] + self::OMITEMPTY_FIELD;
6666
public const OMITEMPTY_STRING_ARRAY_FIELD = [
6767
self::FIELD_TYPE => self::ARRAY,
6868
self::FIELD_ARRAY_TYPE => self::STRING,
@@ -89,7 +89,7 @@ public static function hydrateTime(object $instance, string $field, $value): voi
8989
$instance->{$field} = clone $value;
9090
return;
9191
}
92-
$instance->{$field} = Time\Time::createFromFormat(Time\Time::DefaultFormat, $value);
92+
$instance->{$field} = Time\Time::createFromFormat(\DATE_RFC3339, $value);
9393
}
9494

9595
/**

src/Operator/OperatorAutopilotStateResponse.php renamed to src/Operator/AutopilotStateResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
use DCarbone\PHPConsulAPI\HydratedResponseInterface;
2323

2424
/**
25-
* Class OperatorAutopilotStateResponse
25+
* Class AutopilotStateResponse
2626
*/
27-
class OperatorAutopilotStateResponse extends AbstractValuedResponse implements HydratedResponseInterface
27+
class AutopilotStateResponse extends AbstractValuedResponse implements HydratedResponseInterface
2828
{
2929
/** @var \DCarbone\PHPConsulAPI\Operator\AutopilotState|null */
3030
public ?AutopilotState $AutopilotState = null;

src/Operator/OperatorClient.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ public function AutopilotCASConfiguration(
176176
* @param \DCarbone\PHPConsulAPI\QueryOptions|null $opts
177177
* @throws \GuzzleHttp\Exception\GuzzleException
178178
* @throws \Exception
179-
* @return \DCarbone\PHPConsulAPI\Operator\OperatorServerHealthsResponse
179+
* @return \DCarbone\PHPConsulAPI\Operator\OperatorHealthReplyResponse
180180
*/
181-
public function AutopilotServerHealth(?QueryOptions $opts = null): OperatorServerHealthsResponse
181+
public function AutopilotServerHealth(?QueryOptions $opts = null): OperatorHealthReplyResponse
182182
{
183183
$resp = $this->_requireOK($this->_doGet('v1/operator/autopilot/health', $opts));
184-
$ret = new OperatorServerHealthsResponse();
184+
$ret = new OperatorHealthReplyResponse();
185185
$this->_hydrateResponse($resp, $ret);
186186
return $ret;
187187
}
@@ -190,12 +190,12 @@ public function AutopilotServerHealth(?QueryOptions $opts = null): OperatorServe
190190
* @param \DCarbone\PHPConsulAPI\QueryOptions|null $opts
191191
* @throws \GuzzleHttp\Exception\GuzzleException
192192
* @throws \Exception
193-
* @return \DCarbone\PHPConsulAPI\Operator\OperatorAutopilotStateResponse
193+
* @return \DCarbone\PHPConsulAPI\Operator\AutopilotStateResponse
194194
*/
195-
public function AutopilotState(?QueryOptions $opts = null): OperatorAutopilotStateResponse
195+
public function AutopilotState(?QueryOptions $opts = null): AutopilotStateResponse
196196
{
197197
$resp = $this->_requireOK($this->_doGet('v1/operator/autopilot/state', $opts));
198-
$ret = new OperatorAutopilotStateResponse();
198+
$ret = new AutopilotStateResponse();
199199
$this->_hydrateResponse($resp, $ret);
200200
return $ret;
201201
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DCarbone\PHPConsulAPI\Operator;
4+
5+
/*
6+
Copyright 2016-2021 Daniel Carbone ([email protected])
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
*/
20+
21+
use DCarbone\PHPConsulAPI\AbstractValuedResponse;
22+
use DCarbone\PHPConsulAPI\HydratedResponseInterface;
23+
24+
/**
25+
* Class OperatorServerHealthsResponse
26+
*/
27+
class OperatorHealthReplyResponse extends AbstractValuedResponse implements HydratedResponseInterface
28+
{
29+
/** @var \DCarbone\PHPConsulAPI\Operator\OperatorHealthReply|null */
30+
public ?OperatorHealthReply $OperatorHealthReply = null;
31+
32+
/**
33+
* @return \DCarbone\PHPConsulAPI\Operator\OperatorHealthReply|mixed|null
34+
*/
35+
public function getValue()
36+
{
37+
return $this->OperatorHealthReply;
38+
}
39+
40+
/**
41+
* @param mixed $decodedData
42+
*/
43+
public function hydrateValue($decodedData): void
44+
{
45+
$this->OperatorHealthReply = new OperatorHealthReply((array)$decodedData);
46+
}
47+
}

tests/Usage/Coordinate/CoordinateUsageTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use DCarbone\PHPConsulAPI\Coordinate\Coordinate;
55
use DCarbone\PHPConsulAPI\Coordinate\CoordinateConfig;
66
use function DCarbone\PHPConsulAPI\Coordinate\diff;
7+
use DCarbone\PHPConsulAPI\Coordinate\DimensionalityConflictException;
8+
79
use function DCarbone\PHPConsulAPI\Coordinate\magnitude;
810
use function DCarbone\PHPConsulAPI\Coordinate\unitVectorAt;
911
use DCarbone\PHPConsulAPITests\Usage\AbstractUsageTests;
@@ -73,9 +75,11 @@ public function testCanConstructCoordinateWithDefaultConfig(): void
7375

7476
public function testCanConstructCoordinateWithArrayOfValues(): void
7577
{
76-
$coord = new Coordinate([
77-
'Vec' => [0.1, 0.2],
78-
]);
78+
$coord = new Coordinate(
79+
[
80+
'Vec' => [0.1, 0.2],
81+
]
82+
);
7983
static::assertInstanceOf(Coordinate::class, $coord);
8084
static::assertIsArray($coord->Vec);
8185
static::assertCount(2, $coord->Vec);
@@ -140,7 +144,7 @@ public function testIsCompatibleWith(): void
140144

141145
public function testApplyForce(): void
142146
{
143-
$this->expectException(\DCarbone\PHPConsulAPI\Coordinate\DimensionalityConflictException::class);
147+
$this->expectException(DimensionalityConflictException::class);
144148

145149
$config = CoordinateConfig::Default();
146150
$config->Dimensionality = 3;
@@ -178,7 +182,7 @@ public function testApplyForce(): void
178182

179183
public function testDistanceTo(): void
180184
{
181-
$this->expectException(\DCarbone\PHPConsulAPI\Coordinate\DimensionalityConflictException::class);
185+
$this->expectException(DimensionalityConflictException::class);
182186

183187
$config = CoordinateConfig::Default();
184188
$config->Dimensionality = 3;

tests/Usage/Session/SessionClientUsageTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testNoChecksLifecycle(): void
5353
$session = $sessions[0];
5454

5555
static::assertInstanceOf(Time\Duration::class, $session->LockDelay);
56-
static::assertSame(0, $session->LockDelay->Nanoseconds());
56+
static::assertSame(15 * Time::Second, $session->LockDelay->Nanoseconds());
5757

5858
[$sessions, $wm, $err] = $client->Renew($id);
5959
static::assertNull($err, \sprintf('Error renewing session: %s', $err));
@@ -67,6 +67,7 @@ public function testNoChecksLifecycle(): void
6767

6868
[$sessions, $_, $err] = $client->Info($id);
6969
static::assertNull($err, \sprintf('Error getting list after expected expiration: %s', $err));
70-
static::assertNull($sessions, 'Expected $sessions to be null');
70+
static::assertIsArray($sessions, 'Expected $sessions to be an array');
71+
static::assertCount(0, $sessions, 'Expected $sessions to be empty');
7172
}
7273
}

0 commit comments

Comments
 (0)