diff --git a/src/PAMI/Message/Action/HangupAction.php b/src/PAMI/Message/Action/HangupAction.php index a0ff174d2..a3f7a0236 100644 --- a/src/PAMI/Message/Action/HangupAction.php +++ b/src/PAMI/Message/Action/HangupAction.php @@ -47,12 +47,17 @@ class HangupAction extends ActionMessage * Constructor. * * @param string $channel Channel to hangup. + * @param int $cause Hangup cause. * * @return void */ - public function __construct($channel) + public function __construct($channel, $cause = null) { parent::__construct('Hangup'); $this->setKey('Channel', $channel); + + if (null !== $cause) { + $this->setKey('Cause', $cause); + } } } diff --git a/test/actions/Test_Actions.php b/test/actions/Test_Actions.php index c3f20e1e1..9cad4226a 100644 --- a/test/actions/Test_Actions.php +++ b/test/actions/Test_Actions.php @@ -688,6 +688,21 @@ public function can_hangup() $action = new \PAMI\Message\Action\HangupAction('channel'); $client = $this->_start($write, $action); } + /** + * @test + */ + public function can_hangup_with_cause() + { + $write = array(implode("\r\n", array( + 'action: Hangup', + 'actionid: 1432.123', + 'channel: channel', + 'cause: 5', + '' + ))); + $action = new \PAMI\Message\Action\HangupAction('channel', 5); + $client = $this->_start($write, $action); + } /** * @test */