public function testHandleCheckin() { $server = new DIM_Server(); // should fail authentication $failRet = $server->handleRequest(array("action" => "checkin", "email" => "test", "auth-key" => "test")); $this->assertEquals("0:unauthed", $failRet); $mockAuthenticator = $this->getMock("DIM_Authenticator", array("getConfiguration")); $mockAuthenticator->expects($this->any())->method("getConfiguration")->will($this->returnValue(array("server" => array("users" => array(array("email" => "test", "auth-key" => "test")))))); $server->authenticator = $mockAuthenticator; $stateManager = new DIM_StateManager(); $stateManager->checkOut(); // should successfully check in $successRet = $server->handleRequest(array("action" => "checkin", "email" => "test", "auth-key" => "test")); $this->assertEquals("1", $successRet); $this->assertTrue($stateManager->isCheckedIn()); }
<?php /* This is the server base file that contains the base processing and output. NB - as little code as possible should be here! This will be the root file that is called */ require_once dirname(__FILE__) . "/../lib/server.class.php"; $theServer = new DIM_Server(); echo $theServer->handleRequest($_REQUEST);