public function loginPassProvider()
 {
     $res = array();
     $bad_input = array(null, '', 42, TestData::genUnicodeStr(rand(0, 1) ? rand(1, TestData::MIN_LP_LENGTH) : rand(TestData::MAX_LP_LENGTH, 2 * TestData::MAX_LP_LENGTH)));
     $roles = array('SuperAdmin', 'ContestAdmin', 'Participant');
     //bad data for all roles
     for ($i = 0; $i < sizeof($roles); $i++) {
         $res[] = array(BAD_DATA, TestData::getRandomValue($bad_input), TestData::getRandomValue($bad_input), $roles[$i]);
     }
     //bad data for super admin but good for everyone else
     $lp_len = rand(TestData::MIN_LP_LENGTH, TestData::MAX_LP_LENGTH);
     $res[] = array(BAD_DATA, TestData::genUnicodeStr($lp_len), TestData::genUnicodeStr($lp_len), 'SuperAdmin');
     return $res;
 }
Esempio n. 2
0
 public static function genUserDescription($dataFieldsQnt)
 {
     if ($dataFieldsQnt < 0) {
         throw new InvalidArgumentException();
     }
     $ud = new UserDescription();
     $ud->login = TestData::genUnicodeStr(TestData::ALLOWED_UNICODE_LP_LENGTH);
     $ud->password = TestData::genUnicodeStr(TestData::ALLOWED_UNICODE_LP_LENGTH);
     $ud->userType = TestData::getRandomValue(array('Participant', 'ContestAdmin'));
     for ($i = 0; $i < $dataFieldsQnt; $i++) {
         $ud->dataValue[] = TestData::genUnicodeStr(TestData::MAX_DATA_LENGTH);
     }
     return $ud;
 }
 public function userDataFieldDataProvider()
 {
     $res = array();
     for ($i = 0; $i < 2 * TestData::RANDOM_TESTS_NUMBER; $i++) {
         $cols = array();
         $isGood = TestData::gB();
         for ($j = 1; $j <= rand(1, TestData::MAX_USER_DATA_FIELDS); $j++) {
             if ($isGood) {
                 $cols[] = array(TestData::genUnicodeStr(rand(1, TestData::MAX_DATA_LENGTH)), TestData::gB(), TestData::gB());
             } else {
                 $cols[] = array(TestData::getRandomValue(array(null, '', 42)), TestData::gB(), TestData::gB());
             }
         }
         $res[] = array($isGood, $cols);
     }
     return $res;
 }
 /**
  * @dataProvider sessionUserProvider 
  */
 public function testBadContextForRemoveUserRequest($sessionID, $userID)
 {
     $sessionID = $sessionID == 'session_ok' ? $this->sessionID : $sessionID;
     $userID = $userID == 'user_ok' ? TestData::getRandomValue($this->curUsers)->userID : $userID;
     $req = TestData::fillRequest('RemoveUserRequest', array('sessionID' => $sessionID, 'userID' => $userID));
     $this->assertClassEquals(new RequestFailedResponse(), RequestSender::send($req));
 }