You are here

function CourseObjectUbercartTestCase::testUbercartEnrollment in Course 7

Same name and namespace in other branches
  1. 8.3 modules/course_uc/course_uc.test \CourseObjectUbercartTestCase::testUbercartEnrollment()
  2. 8.2 modules/course_uc/course_uc.test \CourseObjectUbercartTestCase::testUbercartEnrollment()
  3. 6 modules/course_uc/course_uc.test \CourseObjectUbercartTestCase::testUbercartEnrollment()
  4. 7.2 modules/course_uc/course_uc.test \CourseObjectUbercartTestCase::testUbercartEnrollment()

File

modules/course_uc/course_uc.test, line 34

Class

CourseObjectUbercartTestCase
Test class for dealing with adding and removing elements from the course outline.

Code

function testUbercartEnrollment() {
  global $user;
  $this
    ->setCourseTestToProduct();

  // Create a product node.
  $courseNode = $this
    ->createCourseNode(array(
    'sell_price' => 5,
    'unique_hash' => uniqid(),
  ));
  $result = course_enroll_access($courseNode);
  $this
    ->assertFalse($result['success'], 'User prevented from enrolling into paid course.');
  $result = course_enroll_access($courseNode);
  $this
    ->assertFalse($result['success'], 'User prevented from taking paid course.');
  $order = uc_order_new($user->uid);
  uc_order_product_save($order->order_id, $courseNode);
  uc_order_update_status($order->order_id, 'pending');
  uc_order_update_status($order->order_id, 'completed');

  // Check newly granted access to course.
  $result = course_enroll_access($courseNode, $user, TRUE);
  $this
    ->assertTrue($result['success'], 'User granted access to enroll into course.');
  $result = course_take_course_access($courseNode);
  $this
    ->assertTrue($result['success'], 'User granted access to take course.');
}