Exemple #1
0
 /**
  * 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');
 }
 /**
  * Create dummy LRS
  * @return \Lrs
  */
 protected function createLRS()
 {
     $lrs = new Lrs();
     $lrs->title = helpers::getRandomValue();
     $lrs->description = helpers::getRandomValue();
     $lrs->subdomain = helpers::getRandomValue();
     $lrs->api = array('basic_key' => helpers::getRandomValue(), 'basic_secret' => helpers::getRandomValue());
     // $lrs->auth_service = property_exists($this, 'lrsAuthMethod') ? $this->lrsAuthMethod : Lrs::INTERNAL_LRS;
     // $lrs->auth_service_url = property_exists($this, 'auth_service_url') ?
     //     $this->auth_service_url : '';
     // $lrs->token = 'our-token';
     $lrs->owner = array('_id' => Auth::user()->_id);
     $lrs->users = array(array('_id' => Auth::user()->_id, 'email' => Auth::user()->email, 'name' => Auth::user()->name, 'role' => 'admin'));
     $lrs->save();
     $this->lrs = $lrs;
     // Hack header request
     $_SERVER['SERVER_NAME'] = $this->lrs->title . '.com.vn';
     return $lrs;
 }
Exemple #3
0
 protected function createLrs(\User $user)
 {
     $model = new \Lrs(['title' => 'Test', 'owner_id' => $user->_id, 'users' => [['_id' => $user->_id, 'email' => $user->email, 'name' => $user->name, 'role' => 'admin']]]);
     $model->save();
     return $model;
 }