You are here

function UploadPictureTests::testNoPicture in SimpleTest 6

Same name and namespace in other branches
  1. 5 tests/upload_tests.test \UploadPictureTests::testNoPicture()

File

tests/upload_tests.test, line 28

Class

UploadPictureTests

Code

function testNoPicture() {
  $old_pic_set = variable_get('user_pictures', 0);
  variable_set('user_pictures', 1);

  /* Prepare a user to do the stuff */
  $user = $this
    ->drupalCreateUserRolePerm(array(
    'access content',
  ));
  $this
    ->drupalLoginUser($user);

  // not a image
  $img_path = realpath(drupal_get_path('module', 'simpletest') . "/tests/upload_tests.test");
  $edit = array(
    'files[picture_upload]' => $img_path,
  );
  $this
    ->drupalPost('user/' . $user->uid . '/edit', $edit, 'Save');
  $this
    ->assertWantedRaw(t('The selected file %file could not be uploaded. Only JPEG, PNG and GIF images are allowed.', array(
    '%file' => 'upload_tests.test',
  )), 'The uploaded file was not an image.');
  variable_set('user_pictures', $old_pic_set);

  // do we have to check users roles?
  // delete test user and roles
}