7c7
< class ProfileTestCase extends DrupalWebTestCase {
---
> class ProfileTestCase extends DrupalWebTestCase{
18a19,21
>     
>     // This is another normal user-- for checking visibility of fields b/t non-privileged users 
>     $this->normal_user2 = $this->drupalCreateUser();
115a119,267
>   
>   /**
>    * Set the profile field visibility and test for correct behavior
>    *
>    * @param $field
>    *   The field that should have visibility set.
>    * @param $value
>    *   The default value for the field-- needed in order to check field presence on Member listing page-- e.g /profile
>    * @param $visibility
>    *   The value for the visibility field, defaults to 2, public.
>    * @return
>    *   The visibility that has been assigned to the field.
>    */
>   function setProfileFieldVisibility($field, $value = '', $visibility = PROFILE_PUBLIC) {
>     // ensure we are logged in as admin
>   	$this->drupalLogin($this->admin_user);
>   	
>   	//Create field
>     $edit = array(
>       'visibility' => $visibility,
>     );
>     $this->drupalPost('admin/config/people/profile/edit/' . $field['fid'], $edit, t('Save field'));
>     
>     // Check profile page as admin
>     
>     $vis_to_admin = $this->assertText($field['title'], t('Found visible profile field with title %title', array('%title' => $field['title'])));
>     // Check profile page as self
>     
>     // Check profile page as other non-priv user
>     
>     
>     switch ($visibility) {
>     	case PROFILE_PUBLIC:
>     		$this->drupalGet('user/' . $this->normal_user->uid);
>     		$this->assertText($field['title'], t('Profile Public: Found visible profile field with title %title', array('%title' => $field['title'])));
> 
>     		// Check that field is correctly not appearing on member listing page 
>     		$this->drupalGet('profile');
>     		$this->assertNoText($value, t('Profile Public: Profile field %profile correctly NOT displayed on member listing page', array('%profile' => $field['title'])));
>     		break;
>     	case PROFILE_PRIVATE:
>     		// ensure admin can see it
>     		$this->drupalGet('user/' . $this->normal_user->uid);
>     		$this->assertText($field['title'], t('Profile Private: Admin: Found visible profile field with title %title', array('%title' => $field['title'])));
>     		
>     		// ensure normal user cannot see it
>     		$this->drupalLogin($this->normal_user);
>     		$this->drupalGet('user/' . $this->normal_user->uid);
>     		$this->assertText($field['title'], t('Profile Private: User: Self: Found visible profile field with title %title', array('%title' => $field['title'])));
>     		
>     		// ensure other normal user can see it
>         $this->drupalLogin($this->normal_user2);
>         $this->drupalGet('user/' . $this->normal_user->uid);
>         $this->assertNoText($field['title'], t('Profile Private: User: Other: Profile field %title not visibile to non-privileged other user', array('%title' => $field['title'])));
>     		break;
>     	case PROFILE_PUBLIC_LISTINGS:
>     		$this->drupalGet('user/' . $this->normal_user->uid);
>         $this->assertText($field['title'], t('Profile Public Listings: Found visible profile field with title %title', array('%title' => $field['title'])));
>         
>         //Check that field appears on public listing page
>         $this->drupalGet('profile');
>         $this->assertText($value, t('Profile Public Listings: Profile field %profile correctly displayed on member listing page', array('%profile' => $field['title'])));
>         break;
>     	case PROFILE_HIDDEN:
>     		$this->drupalGet('user/' . $this->normal_user->uid);
>     		$this->assertText($field['title'], t('Profile Hidden: Admin: Found visible profile field with title %title', array('%title' => $field['title'])));
>     		
>     		// ensure normal user cannot see it
>         $this->drupalLogin($this->normal_user);
>         $this->drupalGet('user/' . $this->normal_user->uid);
>         $this->assertNoText($field['title'], t('Profile Hidden: User: Self: Profile field %title not visible to non-privileged user', array('%title' => $field['title'])));
>         
>         // ensure other normal user cannot see it
>         $this->drupalLogin($this->normal_user2);
>         $this->drupalGet('user/' . $this->normal_user->uid);
>         $this->assertNoText($field['title'], t('Profile Hidden: User: Other: Profile field %title not visible to non-privileged other user', array('%title' => $field['title'])));
>         break;
>     }
> 
>     //restore to admin user to not break the rest of the test
>     $this->drupalLogin($this->admin_user);
>     return $visibility;
>   } // setProfileFieldVisibility
>   
>   /**
>    * Set the profile field requirement
>    *
>    * @param $field
>    *   The field that should have requirement set.
>    * @param $required
>    *   Boolean value indicating whether or not field should be required.
>    * @return
>    *   The requirement that has been assigned to the field.
>    */
>   function setProfileFieldRequired($field, $required = TRUE) {
>   
>     $edit = array(
>       'required' => $required,
>     );
>     $this->drupalPost('admin/config/people/profile/edit/' . $field['fid'], $edit, t('Save field'));
> 
>     // Check profile page.
>     $profile_edit = $this->drupalGet('user/' . $this->normal_user->uid . '/edit/' . $field['category']);
> 
>     if ($required) {
>       $this->assertRaw($field['title'] . ' <span class="form-required" title="This field is required.">*</span>', t('Found requirement for profile field with title %title', array('%title' => $field['title'])));
>     } // if
>     else {
>       $this->assertNoRaw($field['title'] . ' <span class="form-required" title="This field is required.">*</span>', t('Did not find requirement for profile field with title %title', array('%title' => $field['title'])));
>     } // else
> 
>     return $required;
>   
>   } // setProfileFieldRequired
> 
>   /**
>    * Set the profile field registration form visibility
>    *
>    * @param $field
>    *   The field that should have visibility set.
>    * @param $required
>    *   Boolean value indicating whether or not field should show on the registration form.
>    * @return
>    *   The registration form visibility that has been assigned to the field.
>    */
>   function setProfileFieldRegistrationVisibility($field, $visible = TRUE) {
>   
>     $edit = array(
>       'register' => $visible,
>     );
>     $this->drupalPost('admin/config/people/profile/edit/' . $field['fid'], $edit, t('Save field'));
> 
>     $this->drupalLogout();
> 
>     // Check profile page.
>     $registration_form = $this->drupalGet('user/register');
> 
>     if ($visible) {
>       $this->assertField($field['form_name'], t('Found field with title %title on registration form.', array('%title' => $field['title'])));
>     } // if
>     else {
>       $this->assertNoField($field['form_name'], t('Did not find field with title %title on registration form.', array('%title' => $field['title'])));
>     } // else
> 
>     $this->drupalLogin($this->admin_user);
> 
>     return $visible;
>   
>   } // setProfileFieldRegistrationVisibility
194a347,358
> //      foreach (array(PROFILE_PUBLIC_LISTINGS, PROFILE_PRIVATE, PROFILE_HIDDEN, PROFILE_PUBLIC) as $visibility_setting) {
> //        $this->setProfileFieldVisibility($field, $value, $visibility_setting);
> //      }
>       $this->setProfileFieldVisibility($field, $value, PROFILE_PUBLIC_LISTINGS);
>       $this->setProfileFieldVisibility($field, $value, PROFILE_PRIVATE);
>       $this->setProfileFieldVisibility($field, $value, PROFILE_HIDDEN);
>       $this->setProfileFieldVisibility($field, $value, PROFILE_PUBLIC);
>       
>       $this->setProfileFieldRequired($field, TRUE);
>       $this->setProfileFieldRequired($field, FALSE);
>       $this->setProfileFieldRegistrationVisibility($field, TRUE);
>       $this->setProfileFieldRegistrationVisibility($field, FALSE);
427,429d590
<    * - Test field visibility
<    * - Test required fields
<    * - Test fields on registration form
