diff --git a/src/Ratchet/Component/Server/IpBlackListComponent.php b/src/Ratchet/Component/Server/IpBlackListComponent.php index 1989480..5e2d06c 100644 --- a/src/Ratchet/Component/Server/IpBlackListComponent.php +++ b/src/Ratchet/Component/Server/IpBlackListComponent.php @@ -34,7 +34,9 @@ class IpBlackListComponent implements MessageComponentInterface { * @return IpBlackList */ public function unblockAddress($ip) { - unset($this->_blacklist[$this->filterAddress($ip)]); + if (isset($this->_blacklist[$this->filterAddress($ip)])) { + unset($this->_blacklist[$this->filterAddress($ip)]); + } return $this; } diff --git a/tests/Ratchet/Tests/Component/Server/IpBlackListComponentTest.php b/tests/Ratchet/Tests/Component/Server/IpBlackListComponentTest.php index 874bc5b..c164803 100644 --- a/tests/Ratchet/Tests/Component/Server/IpBlackListComponentTest.php +++ b/tests/Ratchet/Tests/Component/Server/IpBlackListComponentTest.php @@ -84,4 +84,8 @@ class IpBlackListComponentTest extends \PHPUnit_Framework_TestCase { public function testFilterAddress($expected, $input) { $this->assertEquals($expected, $this->_comp->filterAddress($input)); } + + public function testUnblockingSilentlyFails() { + $this->assertInstanceOf('\\Ratchet\\Component\\Server\\IpBlackListComponent', $this->_comp->unblockAddress('localhost')); + } } \ No newline at end of file