public function CourseObjectCommerceTest::testRestrictQty in Course 3.x
File
- modules/
course_commerce/ tests/ src/ Functional/ CourseCommerceTest.php, line 64
Class
- CourseObjectCommerceTest
- Test class for Ubercart integration with Course.
Namespace
Drupal\Tests\course_commerce\FunctionalCode
public function testRestrictQty() {
$this
->setCourseTestToProduct();
// Create a product node.
$courseNode = $this
->createCourseNode(array(
'sell_price' => 5,
'unique_hash' => uniqid(),
));
// Try to add a course to cart twice
$account = $this
->drupalCreateUser();
$this
->drupalLogin($account);
$this
->drupalGet("node/{$courseNode->nid}");
$this
->drupalPostForm(NULL, array(), t('Add to cart'));
$this
->drupalGet("node/{$courseNode->nid}");
$this
->drupalPostForm(NULL, array(), t('Add to cart'));
$this
->assertText(t('This course is already in your'), 'Saw dupe shopping cart message.');
// Now check out.
$order = uc_order_new($account->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');
// Try to re-enroll in a course.
$this
->drupalGet("node/{$courseNode->nid}");
$this
->assertNoRaw(t('Add to cart'), 'Did not see add to cart button.');
}