Exemplo n.º 1
0
 public function testHandleRegister()
 {
     $code = $this->addCode();
     // test wrong code
     $this->post('/auth/register', []);
     $this->assertEquals('200', $this->response->getStatusCode());
     $this->checkErrorCode(AuthController::WrongCode);
     // test illegal email
     $this->post('/auth/register', ["code" => $code]);
     $this->assertEquals('200', $this->response->getStatusCode());
     $this->checkErrorCode(AuthController::IllegalEmail);
     // test password to short
     $shortPwd = '123';
     $this->post('/auth/register', ["code" => $code, "email" => $this->email, "passwd" => $shortPwd]);
     $this->assertEquals('200', $this->response->getStatusCode());
     $this->checkErrorCode(AuthController::PasswordTooShort);
     // test password not equal
     $this->post('/auth/register', ["code" => $code, "email" => $this->email, "passwd" => $this->password, "repasswd" => $shortPwd]);
     $this->assertEquals('200', $this->response->getStatusCode());
     $this->checkErrorCode(AuthController::PasswordNotEqual);
     // test email used
     $this->post('/auth/register', ["code" => $code, "email" => $this->getExistEmail(), "passwd" => $this->password, "repasswd" => $this->password]);
     $this->assertEquals('200', $this->response->getStatusCode());
     $this->checkErrorCode(AuthController::EmailUsed);
     //  illegal register
     Config::set('emailVerifyEnabled', false);
     $this->post('/auth/register', ["code" => $code, "email" => $this->email, "passwd" => $this->password, "repasswd" => $this->password, "name" => "name"]);
     $this->assertEquals('200', $this->response->getStatusCode());
 }
Exemplo n.º 2
0
 public function testHash()
 {
     Config::set('pwdMethod', 'md5');
     $this->hashTest();
     Config::set('pwdMethod', 'sha256');
     $this->hashTest();
     Config::set('pwdMethod', 'default');
     $this->hashTest();
 }
Exemplo n.º 3
0
 public function TestingCache($cache)
 {
     fwrite(STDERR, "test {$cache} cache  ");
     Config::set('cache', $cache);
     $client = Factory::newCache();
     $key = 'key';
     $value = 'value';
     $ttl = 3600;
     $client->set($key, $value, $ttl);
     $this->assertEquals($value, $client->get($key));
     $client->del($key);
     $this->assertEquals(null, $client->get($key));
     // test expired
     $ttl = 1;
     $client->set($key, $value, $ttl);
     sleep(2);
     $this->assertEquals(null, $client->get($key));
     // test wrong key
     $this->assertEquals(null, $client->get(time()));
 }
Exemplo n.º 4
0
 /**
  * Set testing env
  */
 public function setTestingEnv()
 {
     Config::set('env', 'testing');
 }
Exemplo n.º 5
0
 protected function setMuKey()
 {
     Config::set('muKey', $this->muKey);
 }
Exemplo n.º 6
0
 public function testSendDailyMail()
 {
     Config::set('mailDriver', 'file');
     DailyMail::sendDailyMail();
 }