You are here

public function CourseObjectCommerceTest::testBypassFreeCourses in Course 3.x

File

modules/course_commerce/tests/src/Functional/CourseCommerceTest.php, line 93

Class

CourseObjectCommerceTest
Test class for Ubercart integration with Course.

Namespace

Drupal\Tests\course_commerce\Functional

Code

public function testBypassFreeCourses() {
  $this
    ->setCourseTestToProduct();

  // Create a product node.
  $courseNode = $this
    ->createCourseNode(array(
    'sell_price' => 0,
    'unique_hash' => uniqid(),
  ));
  $account = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($account);

  // Default behavior is that add to cart does not show up on a $0 course.
  $this
    ->drupalGet("node/{$courseNode->nid}");
  $this
    ->assertNoRaw(t('Add to cart'));

  // Turn bypass off and check that the add to cart button shows.
  variable_set('course_access_bypass_checkout', 0);
  $this
    ->drupalGet("node/{$courseNode->nid}");
  $this
    ->assertRaw(t('Add to cart'));
}