function UploadPictureTests::testWithGDinvalidSize in SimpleTest 6        
                          
                  
                        Same name and namespace in other branches
- 5 tests/upload_tests.test \UploadPictureTests::testWithGDinvalidSize()
File
 
   - tests/upload_tests.test, line 117
Class
  
  - UploadPictureTests 
Code
function testWithGDinvalidSize() {
  if ($this->_directory_Test) {
    if (image_get_toolkit()) {
      
      $old_pic_set = variable_get('user_pictures', 0);
      variable_set('user_pictures', 1);
      
      $user = $this
        ->drupalCreateUserRolePerm(array(
        'access content',
      ));
      $this
        ->drupalLoginUser($user);
      
      $old_dim = variable_get('user_picture_dimensions', '85x85');
      $old_size = variable_get('user_picture_file_size', '30');
      $img_path = realpath("modules/tests/pictureTesting.jpg");
      $info = image_get_info($img_path);
      
      $test_dim = $info['width'] + 10 . 'x' . ($info['height'] + 10);
      $test_size = floor(filesize($img_path) / 1000) - 1;
      variable_set('user_picture_dimensions', $test_dim);
      variable_set('user_picture_file_size', $test_size);
      
      $edit = array(
        'picture' => $img_path,
      );
      $this
        ->drupalPost('user/' . $user->uid . '/edit', $edit, 'Save');
      $file_dir = variable_get('file_directory_path', 'files');
      $picture_dir = variable_get('user_picture_path', 'pictures');
      $pic_path = $file_dir . '/' . $picture_dir . '/picture-' . $user->uid . '.jpg';
      
      $picture = file_create_url($pic_path);
      
      $content = $this->_browser
        ->getContent();
      $this
        ->assertTrue(strpos($content, $picture), "Image is displayed in user's profile page");
      
      $this
        ->assertTrue(is_file($pic_path), "File is located in proper directory");
      
      variable_set('user_picture_file_size', $old_size);
      variable_set('user_picture_dimensions', $old_dim);
      variable_set('user_pictures', $old_pic_set);
    }
  }
}