You are here

public function OpignoQuizImportAppWebTestCase::tsestCourseImport in Opigno Quiz Import App 7

Test importing a quiz in course context.

File

tests/OpignoQuizImportAppWebTestCase.test, line 98
Defines the unit tests for the Opigno Quiz Import app.

Class

OpignoQuizImportAppWebTestCase
@file Defines the unit tests for the Opigno Quiz Import app.

Code

public function tsestCourseImport() {

  // Create an admin for the course to simplify checking.
  $admin = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $course = $this
    ->createCourse('Course', $admin);

  // Create a user for checking the import.
  $importer = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $this
    ->createRole('can import', array(
    'import quiz questions xls',
  ));
  $this
    ->addMemberToCourse($course, $importer->uid, array(
    'member',
    'can import',
  ));

  // Check import.
  $title = "imported quiz";
  $this
    ->drupalPost('admin/quiz/import/xls', array(
    'files[import_file]' => realpath(drupal_get_path('module', 'opigno_quiz_import_app') . '/tests/fixture/quiz.xlsx'),
    'title' => $title,
  ), t("Import"));
  $this
    ->assertText(t("Your new quiz was imported."));
}