public function testAppend() { $this->assertTrue(f::append($this->tmpFile, ' is awesome')); }
//if page is accessed thorugh ajax if (r::ajax()) { //store sanitized $_POST variables $currentTestData = r::postData(array('test', 'user', 'data')); //get logged user (if any) if ($user = Auth::loggedUser()) { //get user's session page $userSession = site()->find(implode(DS, array(c::get('sessions.folder'), $user->session()))); //istantiate testSession object $tSession = new testSession($userSession, $user->username()); //get user's current session status $userSessionStatus = $user->status(); //if ajaxed $currentTestData equals user's current session status if (str::lower($currentTestData['test']) == str::lower($userSessionStatus)) { //if it was possitble to update user's results file (by appending $currentTestData) if (f::append($tSession->getUserResultsFile(), PHP_EOL . a::json($currentTestData))) { //set updated user's session status to next avalibale test $updatedStatus = $tSession->getNextTest($currentTestData['test']); //if there aren't tests available, set user's session statuts to completed session if (!$updatedStatus) { $updatedStatus = c::get('session.status.completed'); } //update user's session status to next avalibale test $user->update(array('status' => $updatedStatus)); //return to tests page $url = $pages->find(c::get('tests.folder'))->url(); } } } } else { //go to errorPage, since page wasn't accessed through ajax