|
@@ -28,13 +28,13 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
/**
|
|
|
* Tests access to admin settings page and tests default values.
|
|
|
*/
|
|
|
- function testCartLinksUISettingsPage() {
|
|
|
- // Access settings page by anonymous user
|
|
|
+ public function testCartLinksUISettingsPage() {
|
|
|
+ // Access settings page by anonymous user.
|
|
|
$this->drupalGet('admin/store/settings/cart-links');
|
|
|
$this->assertText(t('Access denied'));
|
|
|
$this->assertText(t('You are not authorized to access this page.'));
|
|
|
|
|
|
- // Access settings page by privileged user
|
|
|
+ // Access settings page by privileged user.
|
|
|
$this->drupalLogin($this->adminUser);
|
|
|
$this->drupalGet('admin/store/settings/cart-links');
|
|
|
$this->assertText(
|
|
@@ -67,7 +67,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('Cart Links restrictions is empty.')
|
|
|
);
|
|
|
|
|
|
- // Test presence of and contents of Help page
|
|
|
+ // Test presence of and contents of Help page.
|
|
|
$this->clickLink(t('View the help page'));
|
|
|
$this->assertText(
|
|
|
'http://www.example.com/cart/add/<cart_link_content>',
|
|
@@ -78,32 +78,32 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
/**
|
|
|
* Tests Cart Links on a page under a variety of conditions.
|
|
|
*/
|
|
|
- function testCartLinksBasicFunctionality() {
|
|
|
- // Create product
|
|
|
+ public function testCartLinksBasicFunctionality() {
|
|
|
+ // Create product.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE);
|
|
|
|
|
|
- // Create a product class
|
|
|
+ // Create a product class.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE); // later ...
|
|
|
|
|
|
- // Create some valid Cart Links for these products
|
|
|
+ // Create some valid Cart Links for these products.
|
|
|
$link_array = $this->createValidCartLinks($products);
|
|
|
$cart_links = $link_array['links'];
|
|
|
$link_data = $link_array['data'];
|
|
|
|
|
|
// Need to test incorrect links as well:
|
|
|
- // links which add invalid attributes
|
|
|
- // links which omit required attributes
|
|
|
+ // - links which add invalid attributes.
|
|
|
+ // - links which omit required attributes.
|
|
|
|
|
|
- // Create a page containing these links
|
|
|
+ // Create a page containing these links.
|
|
|
$page = $this->createCartLinksPage($cart_links);
|
|
|
|
|
|
//
|
|
|
- // Test clicking on links
|
|
|
+ // Test clicking on links.
|
|
|
//
|
|
|
|
|
|
foreach ($cart_links as $key => $test_link) {
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
- // Look for link on page
|
|
|
+ // Look for link on page.
|
|
|
$this->assertLink(
|
|
|
t('Cart Link #@link', array('@link' => $key)),
|
|
|
0,
|
|
@@ -116,16 +116,16 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('Cart Link @link found on page.', array('@link' => $test_link))
|
|
|
);
|
|
|
|
|
|
- // Click on link
|
|
|
+ // Click on link.
|
|
|
$this->clickLink(t('Cart Link #@link', array('@link' => $key)));
|
|
|
// Check for notice that item was added (this notice is set ON
|
|
|
- // by default, see admin/store/settings/cart)
|
|
|
+ // by default, see admin/store/settings/cart).
|
|
|
$this->assertText(
|
|
|
t('@title added to your shopping cart.', array('@title' => $link_data[$key]['title'])),
|
|
|
t('Product @title added to cart.', array('@title' => $link_data[$key]['title']))
|
|
|
);
|
|
|
|
|
|
- // Check contents of cart
|
|
|
+ // Check contents of cart.
|
|
|
$this->drupalGet('cart');
|
|
|
$this->assertText(
|
|
|
$link_data[$key]['title'],
|
|
@@ -137,14 +137,14 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('Product quantity correct in cart.')
|
|
|
);
|
|
|
|
|
|
- // Check for correct attribute name(s) in cart
|
|
|
+ // Check for correct attribute name(s) in cart.
|
|
|
foreach ($link_data[$key]['attributes'] as $label => $attribute) {
|
|
|
$this->assertText(
|
|
|
$label . ':',
|
|
|
t('Attribute @label correct in cart.', array('@label' => $label))
|
|
|
);
|
|
|
foreach ($attribute as $option) {
|
|
|
- // Check for correct option name(s) in cart
|
|
|
+ // Check for correct option name(s) in cart.
|
|
|
$this->assertText(
|
|
|
$option,
|
|
|
t('Option @name correct in cart.', array('@name' => $option))
|
|
@@ -153,15 +153,15 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
}
|
|
|
|
|
|
// Use the same link, but this time append an '_s' to turn
|
|
|
- // off message display for this product
|
|
|
+ // off message display for this product.
|
|
|
$this->drupalGet($test_link . '_s');
|
|
|
- // Default add-to-cart message is different when adding a duplicate item
|
|
|
+ // Default add-to-cart message is different when adding a duplicate item.
|
|
|
$this->assertNoText(
|
|
|
t('Your item(s) have been updated.'),
|
|
|
t('Default add-to-cart message suppressed.')
|
|
|
);
|
|
|
|
|
|
- // Empty cart (press remove button)
|
|
|
+ // Empty cart (press remove button).
|
|
|
$this->drupalPost('cart', array(), t('Remove'));
|
|
|
$this->assertText('There are no products in your shopping cart.');
|
|
|
}
|
|
@@ -171,32 +171,32 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
/**
|
|
|
* Tests Cart Links product action messages.
|
|
|
*/
|
|
|
- function testCartLinksProductActionMessage() {
|
|
|
- // Create product
|
|
|
+ public function testCartLinksProductActionMessage() {
|
|
|
+ // Create product.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE);
|
|
|
|
|
|
- // Create a product class
|
|
|
+ // Create a product class.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE); // later ...
|
|
|
|
|
|
- // Create some valid Cart Links for these products
|
|
|
+ // Create some valid Cart Links for these products.
|
|
|
$link_array = $this->createValidCartLinks($products);
|
|
|
$cart_links = $link_array['links'];
|
|
|
$link_data = $link_array['data'];
|
|
|
|
|
|
- // Create a page containing these links
|
|
|
+ // Create a page containing these links.
|
|
|
$page = $this->createCartLinksPage($cart_links);
|
|
|
|
|
|
$this->drupalLogin($this->adminUser);
|
|
|
|
|
|
//
|
|
|
- // Test product action message display
|
|
|
+ // Test product action message display.
|
|
|
//
|
|
|
|
|
|
- // Turn on display of product action message
|
|
|
+ // Turn on display of product action message.
|
|
|
$this->setCartLinksUIProductActionMessage(TRUE);
|
|
|
- // Go to page with Cart Links
|
|
|
+ // Go to page with Cart Links.
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
- // Pick one of the links at random
|
|
|
+ // Pick one of the links at random.
|
|
|
$test_link = array_rand($cart_links);
|
|
|
$this->clickLink(t('Cart Link #@link', array('@link' => $test_link)));
|
|
|
$this->assertText(
|
|
@@ -204,15 +204,15 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('Cart Link product action message found.')
|
|
|
);
|
|
|
|
|
|
- // Empty cart (press remove button)
|
|
|
+ // Empty cart (press remove button).
|
|
|
$this->drupalPost('cart', array(), t('Remove'));
|
|
|
$this->assertText('There are no products in your shopping cart.');
|
|
|
|
|
|
- // Turn off display of product action message
|
|
|
+ // Turn off display of product action message.
|
|
|
$this->setCartLinksUIProductActionMessage(FALSE);
|
|
|
- // Go to page with Cart Links
|
|
|
+ // Go to page with Cart Links.
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
- // Pick one of the links at random
|
|
|
+ // Pick one of the links at random.
|
|
|
$test_link = array_rand($cart_links);
|
|
|
$this->clickLink(t('Cart Link #@link', array('@link' => $test_link)));
|
|
|
$this->assertNoText(
|
|
@@ -226,36 +226,36 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
/**
|
|
|
* Tests Cart Links cart empty action.
|
|
|
*/
|
|
|
- function testCartLinksAllowEmptying() {
|
|
|
- // Create product
|
|
|
+ public function testCartLinksAllowEmptying() {
|
|
|
+ // Create product.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE);
|
|
|
|
|
|
- // Create a product class
|
|
|
+ // Create a product class.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE); // later ...
|
|
|
|
|
|
- // Create some valid Cart Links for these products
|
|
|
+ // Create some valid Cart Links for these products.
|
|
|
$link_array = $this->createValidCartLinks($products);
|
|
|
$cart_links = $link_array['links'];
|
|
|
$link_data = $link_array['data'];
|
|
|
|
|
|
- // Create a page containing these links
|
|
|
+ // Create a page containing these links.
|
|
|
$page = $this->createCartLinksPage($cart_links);
|
|
|
|
|
|
$this->drupalLogin($this->adminUser);
|
|
|
|
|
|
//
|
|
|
- // Test empty cart action
|
|
|
+ // Test empty cart action.
|
|
|
//
|
|
|
|
|
|
- // Allow links to empty cart
|
|
|
+ // Allow links to empty cart.
|
|
|
$this->setCartLinksUIAllowEmptying(TRUE);
|
|
|
- // Go to page with Cart Links
|
|
|
+ // Go to page with Cart Links.
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
- // Pick one of the links at random and add it to the cart
|
|
|
+ // Pick one of the links at random and add it to the cart.
|
|
|
$test_link_0 = array_rand($cart_links);
|
|
|
$this->clickLink(t('Cart Link #@link', array('@link' => $test_link_0)));
|
|
|
|
|
|
- // Pick another link at random and prepend an 'e-' so it will empty cart
|
|
|
+ // Pick another link at random and prepend an 'e-' so it will empty cart.
|
|
|
$in_cart = $cart_links[$test_link_0];
|
|
|
// (Don't want to use the same link.)
|
|
|
unset($cart_links[$test_link_0]);
|
|
@@ -265,10 +265,10 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('The current contents of your shopping cart will be lost. Are you sure you want to continue?'),
|
|
|
t('Empty cart confirmation page found.')
|
|
|
);
|
|
|
- // Allow
|
|
|
+ // Allow.
|
|
|
$this->drupalPost(NULL, array(), t('Confirm'));
|
|
|
|
|
|
- // Verify the cart doesn't have the first item and does have the second item
|
|
|
+ // Verify the cart doesn't have the first item and does have the second item.
|
|
|
$this->drupalGet('cart');
|
|
|
$this->assertText(
|
|
|
$link_data[$test_link]['title'],
|
|
@@ -279,13 +279,13 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('Cart was emptied by Cart Link.')
|
|
|
);
|
|
|
|
|
|
- // Still have something ($test_link) in the cart
|
|
|
+ // Still have something ($test_link) in the cart.
|
|
|
|
|
|
- // Forbid links to empty cart
|
|
|
+ // Forbid links to empty cart.
|
|
|
$this->setCartLinksUIAllowEmptying(FALSE);
|
|
|
- // Re-use $test_link_0 and prepend an 'e-' so it will (try to) empty cart
|
|
|
+ // Re-use $test_link_0 and prepend an 'e-' so it will (try to) empty cart.
|
|
|
$this->drupalGet(str_replace('add/p', 'add/e-p', $in_cart));
|
|
|
- // Verify the cart has both items - cart wasn't emptied
|
|
|
+ // Verify the cart has both items - cart wasn't emptied.
|
|
|
$this->drupalGet('cart');
|
|
|
$this->assertText(
|
|
|
$link_data[$test_link_0]['title'],
|
|
@@ -302,52 +302,52 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
/**
|
|
|
* Tests Cart Links restrictions.
|
|
|
*/
|
|
|
- function testCartLinksRestrictions() {
|
|
|
- // Create product
|
|
|
+ public function testCartLinksRestrictions() {
|
|
|
+ // Create product.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE);
|
|
|
|
|
|
- // Create a product class
|
|
|
+ // Create a product class.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE); // later ...
|
|
|
|
|
|
- // Create some valid Cart Links for these products
|
|
|
+ // Create some valid Cart Links for these products.
|
|
|
$link_array = $this->createValidCartLinks($products);
|
|
|
$cart_links = $link_array['links'];
|
|
|
$link_data = $link_array['data'];
|
|
|
|
|
|
- // Create a page containing these links
|
|
|
+ // Create a page containing these links.
|
|
|
$page = $this->createCartLinksPage($cart_links);
|
|
|
|
|
|
$this->drupalLogin($this->adminUser);
|
|
|
|
|
|
//
|
|
|
- // Test Cart Links restrictions
|
|
|
+ // Test Cart Links restrictions.
|
|
|
//
|
|
|
|
|
|
- // Go to page with Cart Links
|
|
|
+ // Go to page with Cart Links.
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
- // Pick one of the links at random and restrict it
|
|
|
+ // Pick one of the links at random and restrict it.
|
|
|
$test_link_0 = array_rand($cart_links);
|
|
|
// Only this link is allowed - strip '/cart/add/' from beginning
|
|
|
$this->setCartLinksUIRestrictions(substr($cart_links[$test_link_0], 10));
|
|
|
|
|
|
- // Attempt to click link - should pass
|
|
|
+ // Attempt to click link - should pass.
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
$this->clickLink(t('Cart Link #@link', array('@link' => $test_link_0)));
|
|
|
|
|
|
// Check for notice that item was added (this notice is set ON
|
|
|
- // by default, see admin/store/settings/cart)
|
|
|
+ // by default, see admin/store/settings/cart).
|
|
|
$this->assertText(
|
|
|
t('@title added to your shopping cart.', array('@title' => $link_data[$test_link_0]['title'])),
|
|
|
t('Product @title added to cart.', array('@title' => $link_data[$test_link_0]['title']))
|
|
|
);
|
|
|
|
|
|
- // Pick another link at random, as long as it is different from first
|
|
|
+ // Pick another link at random, as long as it is different from first.
|
|
|
$in_cart = $cart_links[$test_link_0];
|
|
|
unset($cart_links[$test_link_0]);
|
|
|
$test_link = array_rand($cart_links);
|
|
|
|
|
|
- // Attempt to click it
|
|
|
- // It should fail and redirect to the home page (default)
|
|
|
+ // Attempt to click it.
|
|
|
+ // It should fail and redirect to the home page (default).
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
$this->clickLink(t('Cart Link #@link', array('@link' => $test_link)));
|
|
|
$this->assertText(
|
|
@@ -358,7 +358,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('Redirected to front page for link not in restrictions.')
|
|
|
);
|
|
|
|
|
|
- // Now create a special redirect page for bad links
|
|
|
+ // Now create a special redirect page for bad links.
|
|
|
$redirect_page = $this->drupalCreateNode(
|
|
|
array(
|
|
|
'body' => array(
|
|
@@ -369,7 +369,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
)
|
|
|
);
|
|
|
|
|
|
- // Set redirect link
|
|
|
+ // Set redirect link.
|
|
|
$this->setCartLinksUIRedirect('node/' . $redirect_page->nid);
|
|
|
|
|
|
// Attempt to click same restricted link as above.
|
|
@@ -381,7 +381,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('Redirected to error page for link not in restrictions.')
|
|
|
);
|
|
|
|
|
|
- // Remove restrictions, try to add again - it should pass
|
|
|
+ // Remove restrictions, try to add again - it should pass.
|
|
|
$this->setCartLinksUIRestrictions('');
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
$this->clickLink(t('Cart Link #@link', array('@link' => $test_link)));
|
|
@@ -413,26 +413,26 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
*
|
|
|
* For additional messages, add additional actions, e.g. "-m99-m1337".
|
|
|
*/
|
|
|
- function testCartLinksMessages() {
|
|
|
+ public function testCartLinksMessages() {
|
|
|
|
|
|
- // Create product
|
|
|
+ // Create product.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE);
|
|
|
|
|
|
- // Create a product class
|
|
|
+ // Create a product class.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE); // later ...
|
|
|
|
|
|
- // Create some valid Cart Links for these products
|
|
|
+ // Create some valid Cart Links for these products.
|
|
|
$link_array = $this->createValidCartLinks($products);
|
|
|
$cart_links = $link_array['links'];
|
|
|
$link_data = $link_array['data'];
|
|
|
|
|
|
- // Create a page containing these links
|
|
|
+ // Create a page containing these links.
|
|
|
$page = $this->createCartLinksPage($cart_links);
|
|
|
|
|
|
- // Need to be admin to define messages
|
|
|
+ // Need to be admin to define messages.
|
|
|
$this->drupalLogin($this->adminUser);
|
|
|
|
|
|
- // Define some messages
|
|
|
+ // Define some messages.
|
|
|
$messages = array();
|
|
|
for ($i = 0; $i < 15; $i++) {
|
|
|
$key = mt_rand(1, 999);
|
|
@@ -441,13 +441,13 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
$this->setCartLinksUIMessages($messages);
|
|
|
|
|
|
//
|
|
|
- // Test message display
|
|
|
+ // Test message display.
|
|
|
//
|
|
|
|
|
|
- // Go to page with Cart Links
|
|
|
+ // Go to page with Cart Links.
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
|
|
|
- // Pick one link at random and append an '-m<#>' to display a message
|
|
|
+ // Pick one link at random and append an '-m<#>' to display a message.
|
|
|
$test_link = array_rand($cart_links);
|
|
|
$message_key = array_rand($messages);
|
|
|
$message_text = explode('|', $messages[$message_key]);
|
|
@@ -457,7 +457,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
t('Message @key displayed.', array('@key' => $message_key))
|
|
|
);
|
|
|
|
|
|
- // Empty cart (press remove button)
|
|
|
+ // Empty cart (press remove button).
|
|
|
$this->drupalPost('cart', array(), t('Remove'));
|
|
|
$this->assertText('There are no products in your shopping cart.');
|
|
|
|
|
@@ -467,50 +467,50 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
/**
|
|
|
* Tests Cart Links tracking.
|
|
|
*/
|
|
|
- function testCartLinksTracking() {
|
|
|
+ public function testCartLinksTracking() {
|
|
|
|
|
|
- // Create product
|
|
|
+ // Create product.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE);
|
|
|
|
|
|
- // Create a product class
|
|
|
+ // Create a product class.
|
|
|
$products[] = $this->createCartLinksProduct(FALSE); // later ...
|
|
|
|
|
|
- // Create some valid Cart Links for these products
|
|
|
+ // Create some valid Cart Links for these products.
|
|
|
$link_array = $this->createValidCartLinks($products);
|
|
|
$cart_links = $link_array['links'];
|
|
|
$link_data = $link_array['data'];
|
|
|
|
|
|
- // Create a page containing these links
|
|
|
+ // Create a page containing these links.
|
|
|
$page = $this->createCartLinksPage($cart_links);
|
|
|
|
|
|
$this->drupalLogin($this->adminUser);
|
|
|
|
|
|
//
|
|
|
- // Test Cart Links tracking
|
|
|
+ // Test Cart Links tracking.
|
|
|
//
|
|
|
|
|
|
- // Go to page with Cart Links
|
|
|
+ // Go to page with Cart Links.
|
|
|
$this->drupalGet('node/' . $page->nid);
|
|
|
|
|
|
- // Create three tracking IDs
|
|
|
+ // Create three tracking IDs.
|
|
|
$tracking = array();
|
|
|
for ($i = 0; $i < 3; $i++) {
|
|
|
$tracking[$this->randomName(16)] = 0;
|
|
|
}
|
|
|
|
|
|
- // Click a number of links to create some statistics
|
|
|
+ // Click a number of links to create some statistics.
|
|
|
for ($i = 0; $i < 50; $i++) {
|
|
|
- // Pick one link at random and append an '-i<tracking ID>'
|
|
|
+ // Pick one link at random and append an '-i<tracking ID>'.
|
|
|
$test_link = array_rand($cart_links);
|
|
|
|
|
|
- // Assign one of the tracking IDs
|
|
|
+ // Assign one of the tracking IDs.
|
|
|
$tracking_id = array_rand($tracking);
|
|
|
$this->drupalGet($cart_links[$test_link] . '-i' . $tracking_id);
|
|
|
- // Keep a record of how many links were assigned this key
|
|
|
+ // Keep a record of how many links were assigned this key.
|
|
|
$tracking[$tracking_id] += 1;
|
|
|
}
|
|
|
|
|
|
- // Check report to see these clicks have been recorded correctly
|
|
|
+ // Check report to see these clicks have been recorded correctly.
|
|
|
$this->drupalGet('admin/store/reports/cart-links');
|
|
|
$total = 0;
|
|
|
foreach ($tracking as $id => $clicks) {
|
|
@@ -538,7 +538,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* TRUE to display product action messages, FALSE to not display.
|
|
|
* Defaults to FALSE.
|
|
|
*/
|
|
|
- function setCartLinksUIProductActionMessage($state = FALSE) {
|
|
|
+ protected function setCartLinksUIProductActionMessage($state = FALSE) {
|
|
|
$this->drupalPost(
|
|
|
'admin/store/settings/cart-links',
|
|
|
array('uc_cart_links_add_show' => $state),
|
|
@@ -560,7 +560,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* TRUE to display product action messages, FALSE to not display.
|
|
|
* Defaults to TRUE.
|
|
|
*/
|
|
|
- function setCartLinksUITrackClicks($state = TRUE) {
|
|
|
+ protected function setCartLinksUITrackClicks($state = TRUE) {
|
|
|
$this->drupalPost(
|
|
|
'admin/store/settings/cart-links',
|
|
|
array('uc_cart_links_track' => 0),
|
|
@@ -582,7 +582,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* TRUE to display product action messages, FALSE to not display.
|
|
|
* Defaults to TRUE.
|
|
|
*/
|
|
|
- function setCartLinksUIAllowEmptying($state = TRUE) {
|
|
|
+ protected function setCartLinksUIAllowEmptying($state = TRUE) {
|
|
|
$this->drupalPost(
|
|
|
'admin/store/settings/cart-links',
|
|
|
array('uc_cart_links_empty' => $state),
|
|
@@ -604,7 +604,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* String containing user input from a textarea, one message per line.
|
|
|
* Messages have numeric key and text value, separated by '|'.
|
|
|
*/
|
|
|
- function setCartLinksUIMessages($messages = '') {
|
|
|
+ protected function setCartLinksUIMessages($messages = '') {
|
|
|
$message_string = implode("\n", $messages);
|
|
|
$this->drupalPost(
|
|
|
'admin/store/settings/cart-links',
|
|
@@ -627,7 +627,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* String containing user input from a textarea, one restriction per line.
|
|
|
* Restrictions are valid Cart Links - i.e. relative URLs.
|
|
|
*/
|
|
|
- function setCartLinksUIRestrictions($restrictions = '') {
|
|
|
+ protected function setCartLinksUIRestrictions($restrictions = '') {
|
|
|
$this->drupalPost(
|
|
|
'admin/store/settings/cart-links',
|
|
|
array('uc_cart_links_restrictions' => $restrictions),
|
|
@@ -648,7 +648,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* @param $url
|
|
|
* Relative URL of the destination page for the redirect. Omit leading '/'.
|
|
|
*/
|
|
|
- function setCartLinksUIRedirect($url = '') {
|
|
|
+ protected function setCartLinksUIRedirect($url = '') {
|
|
|
$this->drupalPost(
|
|
|
'admin/store/settings/cart-links',
|
|
|
array('uc_cart_links_invalid_page' => $url),
|
|
@@ -667,7 +667,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* @param $links
|
|
|
* Array of Cart Links to appear on page.
|
|
|
*/
|
|
|
- public function createCartLinksPage($links = array()) {
|
|
|
+ protected function createCartLinksPage($links = array()) {
|
|
|
if (!empty($links)) {
|
|
|
$i = 0;
|
|
|
foreach ($links as $link) {
|
|
@@ -698,9 +698,9 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* Defaults to FALSE to create a normal product, set to TRUE to
|
|
|
* create a product class instead.
|
|
|
*/
|
|
|
- public function createCartLinksProduct($product_class = FALSE) {
|
|
|
+ protected function createCartLinksProduct($product_class = FALSE) {
|
|
|
|
|
|
- // Create a product
|
|
|
+ // Create a product.
|
|
|
if ($product_class) {
|
|
|
$product = $this->createProductClass();
|
|
|
}
|
|
@@ -708,7 +708,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
$product = $this->createProduct();
|
|
|
}
|
|
|
|
|
|
- // Create some attributes
|
|
|
+ // Create some attributes.
|
|
|
for ($i = 0; $i < 5; $i++) {
|
|
|
$attribute = UbercartAttributeTestCase::createAttribute();
|
|
|
$attributes[$attribute->aid] = $attribute;
|
|
@@ -739,8 +739,8 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
// Load the attributes back.
|
|
|
$loaded_attributes = uc_attribute_load_multiple($aids);
|
|
|
|
|
|
- // TODO: add attributes of all 4 types
|
|
|
- // TODO: create both required and not required attributes
|
|
|
+ // TODO: add attributes of all 4 types.
|
|
|
+ // TODO: create both required and not required attributes.
|
|
|
|
|
|
// Add the selected attributes to the product.
|
|
|
foreach ($loaded_attributes as $loaded_attribute) {
|
|
@@ -750,7 +750,6 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
return $product;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Creates Cart Links pointing to the given product(s).
|
|
|
*
|
|
@@ -770,7 +769,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
* @return
|
|
|
* Array containing Cart Links and link metadata.
|
|
|
*/
|
|
|
- function createValidCartLinks($products = array()) {
|
|
|
+ protected function createValidCartLinks($products = array()) {
|
|
|
foreach ($products as $key => $product) {
|
|
|
$nid = $product->nid;
|
|
|
$title = $product->title;
|
|
@@ -789,7 +788,7 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
// $cart_links and $link_data share the same keys.
|
|
|
$cart_links[$key] = '/cart/add/p' . $nid . '_q' . $qty;
|
|
|
|
|
|
- // Loop over attributes, append all attribute/option combos to links
|
|
|
+ // Loop over attributes, append all attribute/option combos to links.
|
|
|
$attributes = uc_product_get_attributes($nid);
|
|
|
foreach ($attributes as $attribute) {
|
|
|
// If this is textfield, radio, or select option, then
|
|
@@ -800,12 +799,14 @@ class UbercartCartLinksTestCase extends UbercartTestHelper {
|
|
|
$link_data[$key]['attributes'][$attribute->label][] = $value;
|
|
|
$cart_links[$key] .= '_a' . $attribute->aid . 'o' . $value;
|
|
|
break;
|
|
|
+
|
|
|
case 1: // select
|
|
|
case 2: // radios
|
|
|
$option = $attribute->options[array_rand($attribute->options)];
|
|
|
$link_data[$key]['attributes'][$attribute->label][] = $option->name;
|
|
|
$cart_links[$key] .= '_a' . $attribute->aid . 'o' . $option->oid;
|
|
|
break;
|
|
|
+
|
|
|
case 3: // checkboxes
|
|
|
foreach ($attribute->options as $option) {
|
|
|
$link_data[$key]['attributes'][$attribute->label][] = $option->name;
|