Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ phpunit.xml
composer.lock
composer.phar
vendor/*

# IDEs
/.idea/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should never be in the gitignore. They should be in your global gitignore file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't familiar with the global gitignore, thanks

3 changes: 3 additions & 0 deletions lib/Github/HttpClient/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public function addHeaderValue($header, $headerValue)
} else {
$this->headers[$header] = array_merge((array)$this->headers[$header], array($headerValue));
}

$this->removePlugin(Plugin\HeaderAppendPlugin::class);
$this->addPlugin(new Plugin\HeaderAppendPlugin($this->headers));
}

/**
Expand Down
24 changes: 24 additions & 0 deletions test/Github/Tests/HttpClient/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,28 @@ public function shouldAddHeaders()

$client->addHeaders($headers);
}

/**
* @test
*/
public function appendingHeaderShouldAddAndRemovePlugin()
{
$expectedHeaders = [
'Accept' => 'application/vnd.github.v3',
];

$client = $this->getMockBuilder(\Github\HttpClient\Builder::class)
->setMethods(array('removePlugin', 'addPlugin'))
->getMock();

$client->expects($this->once())
->method('removePlugin')
->with(Plugin\HeaderAppendPlugin::class);

$client->expects($this->once())
->method('addPlugin')
->with(new Plugin\HeaderAppendPlugin($expectedHeaders));

$client->addHeaderValue('Accept', 'application/vnd.github.v3');
}
}