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

Commit

Permalink
Merge pull request #53 from Renegade334/queue-filter-hotfix
Browse files Browse the repository at this point in the history
Do not filter non-empty IRC command parameters which cast to boolean false
  • Loading branch information
svpernova09 authored Dec 19, 2018
2 parents fb7525d + 336179b commit 17745ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
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());
}
}

0 comments on commit 17745ef

Please sign in to comment.