/** * @covers IcecastAuth\IcecastAuth::execute */ public function testExecuteRemoveMount() { $_POST = array('action' => 'mount_remove', 'mount' => '/test.mp3', 'server' => 'www.test.fr', 'port' => 8000); $iceAuth = new IcecastAuth(); $mock = $this->getMock('stdClass', array('testCallback')); $mock->expects($this->once())->method('testCallback')->with($this->arrayHasKey('port'))->will($this->returnValue(true)); $iceAuth->setRemoveMountCallback(array($mock, 'testCallback')); $iceAuth->execute(); }
<?php require_once '../vendor/autoload.php'; use IcecastAuth\IcecastAuth; $IceAuth = new IcecastAuth(); // Setup $IceAuth->setAuthCallback('\\authFunc'); // set the callback for authentification $IceAuth->setAuthErrorCallback('\\logError'); $IceAuth->setAddMountCallback('\\logAddMount'); $IceAuth->setRemoveMountCallback('\\logRemoveMount'); $IceAuth->setAddListenerCallback('\\logAddList'); $IceAuth->setRemoveListenerCallback('\\logRemoveList'); $IceAuth->setAuthHeader('HTTP/1.1 200 OK'); // Execute $IceAuth->execute(); // Authetication will work if there is a parameter azerty in the stream url called by user (ex : http://myserver.com/mystream.mp3?azerty=1) function authFunc($parameters) { if (isset($parameters['azerty'])) { return true; } else { return false; } } // Will log Authetication errors in the a file function logErrors($parameters) { _log('Acces refused', $parameters); } function logAddList($parameters)