You are here

ExifCustomHelper.test in EXIF Custom 7

Base test logic for the EXIF Custom module.

File

tests/ExifCustomHelper.test
View source
<?php

/**
 * @file
 * Base test logic for the EXIF Custom module.
 */

/**
 * Base test logic for the EXIF Custom module.
 */
abstract class ExifCustomHelper extends DrupalWebTestCase {

  /**
   * {@inheritdoc}
   */
  public function setUp(array $modules = array()) {

    // Enable this custom module.
    $modules[] = 'exif_custom';
    parent::setUp($modules);

    // Log in as user 1.
    $this
      ->loginUser1();
  }

  /**
   * {@inheritdoc}
   */
  protected function verbose($message, $title = NULL) {

    // Handle arrays, objects, etc.
    if (!is_string($message)) {
      $message = "<pre>\n" . print_r($message, TRUE) . "\n</pre>\n";
    }

    // Optional title to go before the output.
    if (!empty($title)) {
      $title = '<h2>' . check_plain($title) . "</h2>\n";
    }
    parent::verbose($title . $message);
  }

  /**
   * Log in as user 1.
   */
  protected function loginUser1() {
    $password = user_password();

    // Reset the user 1 password.
    $account = user_load(1);
    $edit = array(
      'pass' => $password,
    );
    $account = user_save($account, $edit);
    $account->pass_raw = $password;

    // Log in as user 1.
    $this
      ->drupalLogin($account);
  }

  /**
   * Get a file from the database based on its filename.
   *
   * Taken from file_entity.test.
   *
   * @param $filename
   *   A file filename, usually generated by $this->randomName().
   * @param $reset
   *   (optional) Whether to reset the internal file_load() cache.
   *
   * @return
   *   A file object matching $filename.
   */
  function getFileByFilename($filename, $reset = FALSE) {
    $files = file_load_multiple(array(), array(
      'filename' => $filename,
    ), $reset);

    // Load the first file returned from the database.
    $returned_file = reset($files);
    return $returned_file;
  }

}

Classes

Namesort descending Description
ExifCustomHelper Base test logic for the EXIF Custom module.