public function testCheckin()
 {
     $stateManager = new DIM_StateManager();
     $stateManager->checkIn();
     $this->assertTrue($stateManager->isCheckedIn());
     $this->assertFalse($stateManager->isCheckedOut());
 }
 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());
 }