Commit 4fd70366 authored by P. J. McDermott's avatar P. J. McDermott

Clean up code in gnukebox/tests/SubmissionsTest.php.

parent c2945095
...@@ -21,52 +21,51 @@ ...@@ -21,52 +21,51 @@
require_once('PHPUnit/Framework.php'); require_once('PHPUnit/Framework.php');
require_once('HTTP/Request.php'); require_once('HTTP/Request.php');
class SubmissionsTest extends PHPUnit_Framework_TestCase class SubmissionsTest extends PHPUnit_Framework_TestCase {
{
// Check we can login with standard authentication // Check we can login with standard authentication
public function testStandardAuth() { public function testStandardAuth() {
$result = $this->standardLogin("testuser", "password"); $result = $this->standardLogin('testuser', 'password');
$this->assertEquals("OK", trim($result[0])); $this->assertEquals('OK', trim($result[0]));
sleep(1); sleep(1);
} }
// Make sure we get BADAUTH if we give an incorrect password // Make sure we get BADAUTH if we give an incorrect password
public function testFailedStandardAuth() { public function testFailedStandardAuth() {
$result = $this->standardLogin("testuser", "icanhazsecurity?"); $result = $this->standardLogin('testuser', 'icanhazsecurity?');
$this->assertEquals("BADAUTH", trim($result[0])); $this->assertEquals('BADAUTH', trim($result[0]));
sleep(1); sleep(1);
} }
public function testScrobble() { public function testScrobble() {
$result = $this->standardLogin("testuser", "password"); $result = $this->standardLogin('testuser', 'password');
$this->assertEquals("OK", trim($result[0])); $this->assertEquals('OK', trim($result[0]));
$session_id = trim($result[1]); $session_id = trim($result[1]);
$scrobble_server = trim($result[3]); $scrobble_server = trim($result[3]);
$result = $this->scrobble($scrobble_server, $session_id, "Richard Stallman", $result = $this->scrobble($scrobble_server, $session_id, 'Richard Stallman',
"The Free Software Song", "b25b9595-54ed-7605-8ac2-20b7b2e0a026"); 'The Free Software Song', 'b25b9595-54ed-7605-8ac2-20b7b2e0a026');
$this->assertEquals("OK", trim($result)); $this->assertEquals('OK', trim($result));
sleep(1); sleep(1);
} }
public function testNowPlaying() { public function testNowPlaying() {
$result = $this->standardLogin("testuser", "password"); $result = $this->standardLogin('testuser', 'password');
$this->assertEquals("OK", trim($result[0])); $this->assertEquals('OK', trim($result[0]));
$session_id = trim($result[1]); $session_id = trim($result[1]);
$nowplaying_server = trim($result[2]); $nowplaying_server = trim($result[2]);
$result = $this->nowPlaying($nowplaying_server, $session_id, "The Libre.fm Players", "Let Freedom Ring", $result = $this->nowPlaying($nowplaying_server, $session_id, 'The Libre.fm Players', 'Let Freedom Ring',
"b25b9595-54ed-7605-8ac2-20b7b2e0a026"); 'b25b9595-54ed-7605-8ac2-20b7b2e0a026');
$this->assertEquals("OK", trim($result)); $this->assertEquals('OK', trim($result));
sleep(1); sleep(1);
} }
private function standardLogin($username, $password) { private function standardLogin($username, $password) {
require("../config.php"); require('../config.php');
$timestamp = time(); $timestamp = time();
$token = md5(md5($password) . $timestamp); $token = md5(md5($password) . $timestamp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment