You are here

function UploadPictureTests::testNoPicture in SimpleTest 5

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

File

tests/upload_tests.test, line 30

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
    ->drupalPostRequest('user/' . $user->uid . '/edit', $edit, 'Submit');
  $this
    ->assertWantedText(t('The uploaded file was not an image.'), '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
}