Skip to content

Commit 9ac7107

Browse files
committed
Merged in fonsecas72/bitbucket-api/pass_options_pr_comments (pull request #26)
Pass Pull Request options to Comments when this is called
2 parents 0c36dbc + f9b516e commit 9ac7107

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Bitbucket/API/Api.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ protected function childFactory($name)
295295
/** @var Api $child */
296296
$class = '\\Bitbucket\\API\\'.$name;
297297
$child = new $class($this->client);
298+
$child->setClient($this->getClient());
298299

299300
if ($this->getClient()->hasListeners()) {
300301
$child->getClient()->setListeners($this->getClient()->getListeners());

test/Bitbucket/Tests/API/Http/ClientTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ public function testShouldDoPatchRequestAndReturnResponseInstance()
135135
$this->assertInstanceOf('\Buzz\Message\MessageInterface', $response);
136136
}
137137

138+
public function testClientIsKeptWhenInvokingChildFactory()
139+
{
140+
$options = [
141+
'base_url' => 'localhost'
142+
];
143+
$client = new Client($options);
144+
$pullRequest = new \Bitbucket\API\Repositories\PullRequests();
145+
$pullRequest->setClient($client);
146+
$comments = $pullRequest->comments();
147+
$this->assertSame($client, $comments->getClient());
148+
}
149+
138150
public function testAddListener()
139151
{
140152
$listener = $this->getListenerMock();

0 commit comments

Comments
 (0)