/** * Test LRS */ public function testLRS() { $lrs = new Lrs(); // Test title required. $values = array('title' => '', 'description' => \app\locker\helpers\Helpers::getRandomValue(), 'api' => array('basic_key' => \app\locker\helpers\Helpers::getRandomValue(), 'basic_secret' => \app\locker\helpers\Helpers::getRandomValue())); $validator = $lrs->validate($values); $this->assertTrue($validator->fails()); $this->assertFalse($validator->passes()); $values['title'] = \app\locker\helpers\Helpers::getRandomValue(); $validator = $lrs->validate($values); $this->assertTrue($validator->passes()); // Validate auth_service $values['auth_service_url'] = 'http://' . \app\locker\helpers\Helpers::getRandomValue() . '.adurolms.com'; $validator = $lrs->validate($values); $this->assertTrue($validator->passes()); // Add new lrs $lrs->title = $values['title']; $lrs->description = $values['description']; $lrs->api = $values['api']; $result = $lrs->save(); $this->assertTrue($result); // Load lrs from db $lrs_id = $lrs->_id; $db_lrs = Lrs::find($lrs_id); $this->assertEquals($db_lrs->_id, $lrs->_id); // Edit lrs $title = \app\locker\helpers\Helpers::getRandomValue(); $db_lrs->title = $title; $db_lrs->save(); $this->assertEquals($db_lrs->title, $title); // Delete lrs $db_lrs->delete(); $this->assertEquals(Lrs::find($lrs_id), NULL, 'delete lrs'); }
/** * lrs/{id}/reporting/create * * This test case create new reporting and run report * * It is ensure reporting work correctly. * */ public function testRouterReportCreate() { for ($i = 0; $i < 7; $i++) { $vs = $this->defaultStatment(); $this->statements[] = $this->createStatement($vs, $this->lrs); } $data = array('description' => \app\locker\helpers\Helpers::getRandomValue(), 'name' => '', 'lrs' => $this->lrs->_id, 'query' => array('statement.actor.mbox' => array("mailto:duy.nguyen@go1.com.au"), 'statement.verb.id' => array("http://adlnet.gov/expapi/verbs/experienced"))); //lrs input validation $rules['name'] = 'required|alpha_spaces'; $rules['description'] = 'alpha_spaces'; $validator = Validator::make($data, $rules); $this->assertTrue($validator->fails()); $data['name'] = 'reportabcd'; $data['description'] = 'reportabcd description'; $validator = Validator::make($data, $rules); $this->assertTrue($validator->passes()); // create report. $report = new Report(); $report->lrs = $data['lrs']; $report->query = $data['query']; $report->name = $data['name']; $report->description = $data['description']; $save = $report->save(); $this->assertTrue($save); // Ensure report show in reporting page. $crawler = $this->client->request('GET', "/lrs/{$this->lrs->_id}/reporting"); $this->assertGreaterThan(0, $crawler->filter('html:contains("reportabcd")')->count()); $this->assertGreaterThan(0, $crawler->filter('html:contains("reportabcd description")')->count()); $crawler = $this->client->request('GET', "/lrs/{$this->lrs->_id}/reporting/show/{$report->_id}"); $this->assertGreaterThan(0, $crawler->filter('html:contains("Number of statements")')->count()); $this->assertGreaterThan(0, $crawler->filter('html:contains("7")')->count()); // Delete report by router. $crawler = $this->client->request('DELETE', "/lrs/{$this->lrs->_id}/reporting/delete/{$report->_id}"); $this->assertEquals(Report::find($report->_id), NULL); }
/** * Test Activity */ public function testActivityCRUD() { $activity = new Activity(); $activity->_id = \app\locker\helpers\Helpers::getRandomValue(); $activity->definition = array('type' => \app\locker\helpers\Helpers::getRandomValue(), 'name' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue()), 'description' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue())); $result = $activity->save(); $this->assertTrue($result); // Load activity from db $aid = $activity->_id; $db_activity = Activity::find($aid); $this->assertEquals($db_activity->_id, $activity->_id); // Delete activity $db_activity->delete(); $this->assertEquals(Activity::find($aid), NULL); }
public function create($input) { $user = \Auth::user(); $app = new OAuthApp(); $app->name = $input['name']; $app->description = $input['description']; $app->website = $input['website']; $app->callbackurl = $input['callback']; $app->rules = $input['rules']; $app->client_id = \app\locker\helpers\Helpers::getRandomValue(); $app->secret = \app\locker\helpers\Helpers::getRandomValue(); $app->organisation = array('name' => $input['organisation'] ? $input['organisation'] : '', 'website' => $input['org_url'] ? $input['org_url'] : ''); $app->owner = array('_id' => $user->_id, 'email' => $user->email, 'name' => $user->name, 'role' => $user->role); $result = $app->save() ? true : false; $this->oauthDetails($app->_id, $input['name'], $app->client_id, $app->secret, 1, $input['callback']); return $result; }
protected function dummyEmail() { return helpers::getRandomValue() . '@go1.com.au'; }
/** * Generate a new key and secret for basic auth * **/ public function editCredentials($id) { $lrs = $this->lrs->find($id); $lrs->api = array('basic_key' => \app\locker\helpers\Helpers::getRandomValue(), 'basic_secret' => \app\locker\helpers\Helpers::getRandomValue()); if ($lrs->save()) { $message_type = 'success'; $message = Lang::get('update_key'); } else { $message_type = 'error'; $message = Lang::get('update_key_error'); } return Redirect::back()->with($message_type, $message); }