Ejemplo n.º 1
0
 /**
  * UserTest::testUserDataIntegrity()
  * 
  * @return void
  */
 public function testUserDataIntegrity()
 {
     # See if basic data matched
     $pilot = PilotData::getPilotByEmail('*****@*****.**');
     foreach ($this->registrationData as $key => $value) {
         if ($key == 'password') {
             continue;
         }
         $this->assertEquals($value, $pilot->{$key}, "Checking {$key}");
     }
     # Did they get added to the default group?
     $defaultGroup = SettingsData::getSettingValue('DEFAULT_GROUP');
     $pilotGroups = PilotGroups::getUserGroups($pilot->pilotid);
     $this->assertNotEmpty($pilotGroups, 'PilotGroups::getUserGroups()');
     $found = false;
     foreach ($pilotGroups as $group) {
         if (strtolower(trim($group->name)) == strtolower(trim($defaultGroup))) {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found, 'User found in default group');
 }
Ejemplo n.º 2
0
 /**
  * UserTest::testUserStatusChanges()
  * 
  * @return void
  */
 public function testUserStatusChanges()
 {
     $pilot = PilotData::getPilotByEmail('*****@*****.**');
     # Go through all the statuses
     $status_type_list = Config::get('PILOT_STATUS_TYPES');
     foreach ($status_type_list as $id => $status) {
         $save = PilotData::updateProfile($pilot->pilotid, array('retired' => $id));
         $pilotGroups = PilotGroups::getUserGroups($pilot->pilotid);
         # Check if they are in the proper groups:
         foreach ($status['group_add'] as $group) {
             #$this->assertTrue(PilotGroups::checkUserInGroup($pilot->pilotid, $group), "Error adding to \"$group\" for {$status['name']}");
             $found = false;
             foreach ($pilotGroups as $pilot_group) {
                 if ($pilot_group->name === $group) {
                     $found = true;
                     break;
                 }
             }
             $this->assertTrue($found, "Error adding to \"{$group}\" for {$status['name']}");
         }
         foreach ($status['group_remove'] as $group) {
             $this->assertNotTrue(PilotGroups::CheckUserInGroup($pilot->pilotid, $group));
         }
     }
     /* Set the user back to the default status */
     foreach ($status_type_list as $id => $status) {
         if ($status['default'] == false) {
             continue;
         }
         $save = PilotData::updateProfile($pilot->pilotid, array('retired' => $id));
         # Check if they are in the proper groups:
         foreach ($status['group_add'] as $group) {
             $this->assertTrue(PilotGroups::CheckUserInGroup($pilot->pilotid, $group), "Error adding to \"{$group}\" for {$status['name']}");
         }
         foreach ($status['group_remove'] as $group) {
             $this->assertNotTrue(PilotGroups::CheckUserInGroup($pilot->pilotid, $group));
         }
     }
 }