diff --git a/src/Debugger/DebuggerClient.php b/src/Debugger/DebuggerClient.php index 6caa12291e08..f6ae8e0922ba 100644 --- a/src/Debugger/DebuggerClient.php +++ b/src/Debugger/DebuggerClient.php @@ -141,7 +141,7 @@ public function debuggee($id = null, array $options = []) */ public function debuggees(array $extras = []) { - $res = $this->connection->listDebuggees(['projectId' => $this->projectId] + $extras); + $res = $this->connection->listDebuggees(['project' => $this->projectId] + $extras); if (is_array($res) && array_key_exists('debuggees', $res)) { return array_map(function ($info) { return new Debuggee($this->connection, $info); diff --git a/tests/system/Debugger/BasicTest.php b/tests/system/Debugger/BasicTest.php new file mode 100644 index 000000000000..412dfb59dc73 --- /dev/null +++ b/tests/system/Debugger/BasicTest.php @@ -0,0 +1,114 @@ +debuggerClient = new DebuggerClient([ + 'keyFilePath' => getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH') + ]); + } + + /** + * @dataProvider transports + */ + public function testCanListDebuggees($transport) + { + $debuggerClient = $this->getClient($transport); + + $debuggees = $debuggerClient->debuggees(); + $this->assertInternalType('array', $debuggees); + $this->assertContainsOnlyInstancesOf( + Debuggee::class, + $debuggees + ); + } + + /** + * @dataProvider transports + */ + public function testRegisterSetUseBreakpoint($transport) + { + $debuggerClient = $this->getClient($transport); + + $debuggee = $debuggerClient->debuggee('', [ + 'uniquifier' => 'debugger-system-test', + 'description' => 'Debugger System Test' + ]); + + // Register the debuggee + $debuggee->register(); + $this->assertNotEmpty($debuggee->id()); + + // Set a breakpoint + $client = new GapicClient(); + $breakpoint = new GapicBreakpoint(); + $location = new SourceLocation(); + $location->setPath('web/app.php'); + $location->setLine(10); + $breakpoint->setLocation($location); + $resp = $client->setBreakpoint($debuggee->id(), $breakpoint, 'google.com/php/v0.1'); + $bp = $resp->getBreakpoint(); + $this->assertNotEmpty($bp->getId()); + + // Fetch the list of breakpoints + $breakpoints = $debuggee->breakpoints(); + $this->assertInternalType('array', $breakpoints); + $this->assertContainsOnlyInstancesOf( + Breakpoint::class, + $breakpoints + ); + + // fulfill a breakpoint + $breakpoint = $breakpoints[0]; + $breakpoint->finalize(); + $debuggee->updateBreakpoint($breakpoint); + } + + public function getClient($transport) + { + return new DebuggerClient([ + 'transport' => $transport, + 'keyFilePath' => getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH') + ]); + } + + public function transports() + { + return [ + ['grpc'], + ['rest'] + ]; + } +} diff --git a/tests/unit/Debugger/DebuggerClientTest.php b/tests/unit/Debugger/DebuggerClientTest.php index 7b67d426da7a..2930e12000c2 100644 --- a/tests/unit/Debugger/DebuggerClientTest.php +++ b/tests/unit/Debugger/DebuggerClientTest.php @@ -39,7 +39,7 @@ public function setUp() public function testListsDebuggees() { - $this->connection->listDebuggees(['projectId' => 'project1'])->willReturn([ + $this->connection->listDebuggees(['project' => 'project1'])->willReturn([ 'debuggees' => [ ['id' => 'debuggee1', 'project' => 'project1'], ['id' => 'debuggee2', 'project' => 'project1'], @@ -54,7 +54,7 @@ public function testListsDebuggees() public function testListsDebuggeesEmpty() { - $this->connection->listDebuggees(['projectId' => 'project1'])->willReturn([]); + $this->connection->listDebuggees(['project' => 'project1'])->willReturn([]); $this->client->setConnection($this->connection->reveal()); $debuggees = $this->client->debuggees(); $this->assertCount(0, $debuggees);