Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Do not filter non-empty IRC command parameters which cast to boolean false #53

Merged
merged 1 commit into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/EventQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function queueRequest(UserEventInterface $event, $command, array $para
{
$event->setPrefix($this->prefix);
$event->setCommand($command);
$event->setParams(array_filter($params));
$event->setParams(array_filter($params, 'strlen'));
$this->queue->insert($event, $this->getPriority($command, $params));
}

Expand Down
23 changes: 23 additions & 0 deletions tests/EventQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,27 @@ public function testNonDestructiveIteration()

$this->assertEquals([ $event ], $contents);
}

/**
* Tests that non-empty parameter strings are not truncated.
*/
public function testRequestFilter()
{
$this->assertNull($this->queue->extract());

$this->queue->ircMode('#test', '+n', '');
$this->queue->ircPrivmsg('TestUser', '0');

$event = $this->queue->extract();
$this->assertInstanceOf('\Phergie\Irc\Event\EventInterface', $event);
$this->assertEquals('MODE', $event->getCommand());
$this->assertEquals([ '#test', '+n' ], $event->getParams());

$event = $this->queue->extract();
$this->assertInstanceOf('\Phergie\Irc\Event\EventInterface', $event);
$this->assertEquals('PRIVMSG', $event->getCommand());
$this->assertEquals([ 'TestUser', '0' ], $event->getParams());

$this->assertNull($this->queue->extract());
}
}