Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 7
level: 8
paths:
- src/
- tests/
Expand Down
4 changes: 2 additions & 2 deletions src/Auth/TokenSources/CLITokenSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function parseFile(string $filename): void
}

/**
* @return array{project_name?: string, 'oauth_token': array{'accesstoken': string, 'expiresin': int, 'expiry': string, 'refreshtoken': string, 'tokentype': string}}
* @return array{project_name?: string, 'oauth_token': array{'accesstoken': string, 'expiresin': int, 'expiry': non-falsy-string|null, 'refreshtoken': string|null, 'tokentype': string}}
*/
protected function toFile(): array
{
Expand All @@ -80,7 +80,7 @@ protected function toFile(): array
'oauth_token' => [
'accesstoken' => $this->accessToken,
'expiresin' => $this->expiresIn,
'expiry' => $this->expiry->format(DATE_RFC3339_EXTENDED),
'expiry' => $this->expiry?->format(DATE_RFC3339_EXTENDED),
'refreshtoken' => $this->refreshToken,
'tokentype' => $this->tokenType,
],
Expand Down
8 changes: 8 additions & 0 deletions src/Compute/Models/Machine.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public function updatedFields(): array
*/
public function stop(StopMachineRequest $request = new StopMachineRequest()): Operation
{
assert($this->client !== null);

return $this->client->stop($this->getID(), $request);
}

Expand All @@ -151,6 +153,8 @@ public function stop(StopMachineRequest $request = new StopMachineRequest()): Op
*/
public function start(StartMachineRequest $request = new StartMachineRequest()): Operation
{
assert($this->client !== null);

return $this->client->start($this->getID(), $request);
}

Expand All @@ -161,6 +165,8 @@ public function start(StartMachineRequest $request = new StartMachineRequest()):
*/
public function reset(ResetMachineRequest $request = new ResetMachineRequest()): Operation
{
assert($this->client !== null);

return $this->client->reset($this->getID(), $request);
}

Expand All @@ -171,6 +177,8 @@ public function reset(ResetMachineRequest $request = new ResetMachineRequest()):
*/
public function delete(DeleteMachineRequest $request = new DeleteMachineRequest()): Operation
{
assert($this->client !== null);

return $this->client->delete($this->getID(), $request);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Integration/Compute/MachinesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,21 @@ protected function tearDown(): void

public function test_list_machines(): void
{
assert($this->client !== null);
$response = $this->client->machines()->list();
self::assertGreaterThan(0, count($response->getMachines()), 'Expected at least one machine');
}

public function test_get_machine(): void
{
assert($this->client !== null);
$machine = $this->client->machines()->get('php-cbws-test1');
self::assertEquals('zones/nl-ein-1/types/g2.1', $machine->getType(), 'Expected machine to have g2.1 type');
}

public function test_stop_machine(): void
{
assert($this->client !== null);
$machine = $this->client->machines()->get('php-cbws-test1');
$operation = $machine->stop()->await();

Expand All @@ -71,6 +74,7 @@ public function test_stop_machine(): void

public function test_start_machine(): void
{
assert($this->client !== null);
$machine = $this->client->machines()->get('php-cbws-test1');
$operation = $machine->start()->await();

Expand Down