public function CourseObjectUbercartTestCase::testRestrictQty in Course 7.2
Same name and namespace in other branches
- 8.3 modules/course_uc/course_uc.test \CourseObjectUbercartTestCase::testRestrictQty()
- 8.2 modules/course_uc/course_uc.test \CourseObjectUbercartTestCase::testRestrictQty()
- 7 modules/course_uc/course_uc.test \CourseObjectUbercartTestCase::testRestrictQty()
File
- modules/
course_uc/ course_uc.test, line 74
Class
- CourseObjectUbercartTestCase
- Test class for dealing with adding and removing elements from the course outline.
Code
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
->drupalPost(NULL, array(), t('Add to cart'));
$this
->drupalGet("node/{$courseNode->nid}");
$this
->drupalPost(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.');
}