Skip to content

Commit

Permalink
Fix new_chat_members event (#19)
Browse files Browse the repository at this point in the history
* Fix new_chat_members event

* Apply fixes from StyleCI (#18)
  • Loading branch information
mpociot authored Oct 20, 2017
1 parent d6e067f commit b3f2c86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/TelegramDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public function matchesRequest()
public function hasMatchingEvent()
{
$event = false;
if ($this->event->has('new_chat_member')) {
$event = new GenericEvent($this->event->get('new_chat_member'));
$event->setName('new_chat_member');
if ($this->event->has('new_chat_members')) {
$event = new GenericEvent($this->event->get('new_chat_members'));
$event->setName('new_chat_members');
}

if ($this->event->has('left_chat_member')) {
Expand Down
16 changes: 9 additions & 7 deletions tests/TelegramDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,20 @@ public function it_calls_new_chat_member_event()
],
'date' => '1480369277',
'text' => 'Hi Julia',
'new_chat_member' => [
'id' => '456',
'first_name' => 'Marcel',
'last_name' => 'Pociot',
'username' => 'mpociot',
'new_chat_members' => [
[
'id' => '456',
'first_name' => 'Marcel',
'last_name' => 'Pociot',
'username' => 'mpociot',
],
],
],
]);
$event = $driver->hasMatchingEvent();
$this->assertInstanceOf(GenericEvent::class, $event);
$this->assertSame('new_chat_member', $event->getName());
$this->assertSame('Marcel', $event->getPayload()['first_name']);
$this->assertSame('new_chat_members', $event->getName());
$this->assertSame('Marcel', $event->getPayload()[0]['first_name']);
}

/** @test */
Expand Down

0 comments on commit b3f2c86

Please sign in to comment.