Skip to content

Commit cb4acd2

Browse files
committed
Set correct value for channel in constructor
Fixes #3. This was a typo where username from the config was being used for the channel provided through the constructor. This affected users wanting to use the default channel in the config rather than using an explicit to() at runtime.
1 parent f559d6f commit cb4acd2

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/Maknz/Slack/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ class Client {
6969
/**
7070
* Instantiate a new client
7171
*
72-
* @param array $config
73-
* @param \GuzzleHttp\Client $guzzle
72+
* @param string $endpoint The Slack webhook
7473
* @param array $attributes
74+
* @param \GuzzleHttp\Client $guzzle
7575
* @return void
7676
*/
7777
public function __construct($endpoint, array $attributes = [], Guzzle $guzzle = null)
7878
{
7979
$this->setEndpoint($endpoint);
8080

81-
if (isset($attributes['channel'])) $this->setChannel($attributes['username']);
81+
if (isset($attributes['channel'])) $this->setChannel($attributes['channel']);
8282

8383
if (isset($attributes['username'])) $this->setUsername($attributes['username']);
8484

tests/ClientUnitTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,25 @@ public function testSetIconToUrl()
149149
$this->assertEquals('http://www.fake.com/someimage.png', $client->getIcon());
150150
}
151151

152+
public function testInstantiationSetsCorrectValues()
153+
{
154+
$data = [
155+
'channel' => '#test',
156+
'username' => 'Test Username',
157+
'icon' => ':heart_eyes:'
158+
];
159+
160+
$client = new Client($this->getEndpoint(), $data);
161+
162+
$this->assertEquals('#test', $client->getChannel());
163+
164+
$this->assertEquals('Test Username', $client->getUsername());
165+
166+
$this->assertEquals(':heart_eyes:', $client->getIcon());
167+
168+
$this->assertEquals(Client::ICON_TYPE_EMOJI, $client->getIconType());
169+
}
170+
152171
private function getClient()
153172
{
154173
return new Client($this->getEndpoint());

0 commit comments

Comments
 (0)