Skip to content

Commit a34641e

Browse files
committed
Fixed risky tests for compute/appengine functions
1 parent 784ca19 commit a34641e

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

auth/test/CommandTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,18 @@ public function testAuthCloudExplicitCommand()
5151

5252
public function testAuthCloudExplicitComputeEngineCommand()
5353
{
54-
$this->setExpectedException('Google\Cloud\Core\Exception\ServiceException');
54+
#$this->setExpectedException('Google\Cloud\Core\Exception\ServiceException');
5555
$output = $this->runCommand(
5656
'auth-cloud-explicit-compute-engine', null, $this->projectId);
57+
$this->assertContains('Undefined index: access_token', $output);
5758
}
5859

5960
public function testAuthCloudExplicitAppEngineCommand()
6061
{
61-
$this->setExpectedException('Google\Cloud\Core\Exception\ServiceException');
62+
#$this->setExpectedException('Google\Cloud\Core\Exception\ServiceException');
6263
$output = $this->runCommand(
6364
'auth-cloud-explicit-app-engine', null, $this->projectId);
65+
$this->assertContains('Undefined index: access_token', $output);
6466
}
6567

6668
private function runCommand($commandName, $serviceAccountPath=null, $projectId=null)
@@ -78,12 +80,18 @@ private function runCommand($commandName, $serviceAccountPath=null, $projectId=n
7880
['interactive' => false]
7981
);
8082
} else if ($projectId) {
81-
$commandTester->execute(
82-
[
83-
'projectId'=> $projectId
84-
],
85-
['interactive' => false]
86-
);
83+
try {
84+
$commandTester->execute(
85+
[
86+
'projectId'=> $projectId
87+
],
88+
['interactive' => false]
89+
);
90+
} catch (\Google\Cloud\Core\Exception\ServiceException $e) {
91+
ob_get_clean();
92+
$application->renderException($e, $commandTester->getOutput());
93+
return $commandTester->getDisplay();
94+
}
8795
} else {
8896
$commandTester->execute([], ['interactive' => false]);
8997
}

0 commit comments

Comments
 (0)