Skip to content

Commit

Permalink
Debugger: Fix loading source context as array from source-contexts.js…
Browse files Browse the repository at this point in the history
…on (#1102)

* Failing test for providing extSourceContexts as an array rather than object

* Fix case where extended source context is already the serialized version

* Fix typo
  • Loading branch information
chingor13 authored Jun 13, 2018
1 parent a4e7e52 commit 9f4c28d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Debugger/src/Debuggee.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function info()
return is_array($esc) ? $esc['context'] : $esc->context()->info();
}, $this->extSourceContexts),
'extSourceContexts' => array_map(function ($esc) {
return $esc->info();
return is_array($esc) ? $esc : $esc->info();
}, $this->extSourceContexts)
];
if ($this->status) {
Expand Down
17 changes: 17 additions & 0 deletions Debugger/tests/Unit/DebuggeeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,21 @@ public function testRegisterSetsDebuggeeId()
$this->assertTrue($debuggee->register());
$this->assertEquals('debuggee1', $debuggee->id());
}

public function testDebuggeeExtendedSourceContextSerialization()
{
$debuggee = new Debuggee($this->connection->reveal(), [
'project' => 'project1',
'extSourceContexts' => [
[
'context' => []
]
]
]);
$info = $debuggee->info();
$this->assertArrayHasKey('extSourceContexts', $info);
$this->assertCount(1, $info['extSourceContexts']);
$this->assertArrayHasKey('sourceContexts', $info);
$this->assertCount(1, $info['sourceContexts']);
}
}

0 comments on commit 9f4c28d

Please sign in to comment.