You are here

public function UbercartCartLinksTestCase::testCartLinksProductActionMessage in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_cart_links/uc_cart_links.test \UbercartCartLinksTestCase::testCartLinksProductActionMessage()

Tests Cart Links product action messages.

File

uc_cart_links/tests/uc_cart_links.test, line 174
Ubercart Cart Links Tests.

Class

UbercartCartLinksTestCase
SimpleTests for Ubercart Cart Links.

Code

public function testCartLinksProductActionMessage() {

  // Create product.
  $products[] = $this
    ->createCartLinksProduct(FALSE);

  // Create a product class.
  $products[] = $this
    ->createCartLinksProduct(FALSE);

  // later ...
  // 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.
  $page = $this
    ->createCartLinksPage($cart_links);
  $this
    ->drupalLogin($this->adminUser);

  //
  // Test product action message display.
  //
  // Turn on display of product action message.
  $this
    ->setCartLinksUIProductActionMessage(TRUE);

  // Go to page with Cart Links.
  $this
    ->drupalGet('node/' . $page->nid);

  // 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(t('Cart Link product action: @link', array(
    '@link' => substr($cart_links[$test_link], 10),
  )), t('Cart Link product action message found.'));

  // 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.
  $this
    ->setCartLinksUIProductActionMessage(FALSE);

  // Go to page with Cart Links.
  $this
    ->drupalGet('node/' . $page->nid);

  // 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(t('Cart Link product action: @link', array(
    '@link' => substr($cart_links[$test_link], 10),
  )), t('Cart Link product action message not present.'));
  $this
    ->drupalLogout();
}