diff --git a/modules/cart/tests/commerce_cart.test b/modules/cart/tests/commerce_cart.test index da87246d..36be9e85 100644 --- a/modules/cart/tests/commerce_cart.test +++ b/modules/cart/tests/commerce_cart.test @@ -81,7 +81,7 @@ class CommerceCartTestCaseSimpleProduct extends CommerceCartTestCase { // Go to cart url. $this->drupalGet('node/' . $this->product_node->nid); - $this->assertField('edit-submit', t('Add to cart button exists')); + $this->assertField('edit-submit', 'Add to cart button exists'); } /** @@ -90,15 +90,15 @@ class CommerceCartTestCaseSimpleProduct extends CommerceCartTestCase { public function testCommerceCartAdd() { // Ensure the add to cart message is displayed. $message = t('%title added to your cart.', array('%title' => $this->product_node->title, '!cart-url' => url('cart'))); - $this->assertRaw($message, t('Product add to cart message displayed.')); + $this->assertRaw($message, 'Product add to cart message displayed.'); // Go to cart url. $this->drupalGet($this->getCommerceUrl('cart')); // Test if the page resolves and there is something in the cart. $this->assertResponse(200); - $this->assertNoText(t('Your shopping cart is empty.'), t('Cart is not empty')); - $this->assertText($this->product->title, t('Product was added to the cart')); + $this->assertNoText(t('Your shopping cart is empty.'), 'Cart is not empty'); + $this->assertText($this->product->title, 'Product was added to the cart'); } /** @@ -111,15 +111,15 @@ class CommerceCartTestCaseSimpleProduct extends CommerceCartTestCase { $this->drupalGet($this->getCommerceUrl('cart')); // Check remove button. - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-delete')]", NULL, t('Remove button present')); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-delete')]", NULL, 'Remove button present'); // Check quantity field. - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", NULL, t('Quantity field present')); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", 1, t('Quantity field has correct number of items')); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", NULL, 'Quantity field present'); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", 1, 'Quantity field has correct number of items'); // Check if the Update cart and Checkout buttons are present. - $this->assertField("edit-submit", t('Update cart button present')); - $this->assertField("edit-checkout", t('Checkout button present')); + $this->assertField("edit-submit", 'Update cart button present'); + $this->assertField("edit-checkout", 'Checkout button present'); } /** @@ -129,7 +129,7 @@ class CommerceCartTestCaseSimpleProduct extends CommerceCartTestCase { // Load the current order of the user. $order = commerce_cart_order_load($this->store_customer->uid); $products = array(); - $this->assertTrue(commerce_cart_order_is_cart($order), t('User has currently an order in cart status.')); + $this->assertTrue(commerce_cart_order_is_cart($order), 'User has currently an order in cart status.'); // Get the products out of the order and store them in an array. foreach (entity_metadata_wrapper('commerce_order', $order)->commerce_line_items as $delta => $line_item_wrapper) { if (in_array($line_item_wrapper->getBundle(), commerce_product_line_item_types())) { @@ -138,7 +138,7 @@ class CommerceCartTestCaseSimpleProduct extends CommerceCartTestCase { } } // Check if the product is in the products array for the order. - $this->assertTrue(in_array($this->product->product_id, array_keys($products)), t('Product is actually in the cart')); + $this->assertTrue(in_array($this->product->product_id, array_keys($products)), 'Product is actually in the cart'); } /** @@ -153,7 +153,7 @@ class CommerceCartTestCaseSimpleProduct extends CommerceCartTestCase { $qty = $this->xpath("//input[starts-with(@name, 'edit_quantity')]"); $this->drupalPost($this->getCommerceUrl('cart'), array((string) $qty[0]['name'] => 2), t('Update cart')); // Check if the amount has been really changed. - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", 2, t('Cart updated with new quantity')); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", 2, 'Cart updated with new quantity'); } /** @@ -165,7 +165,7 @@ class CommerceCartTestCaseSimpleProduct extends CommerceCartTestCase { // Remove the product from the cart. $this->drupalPost(NULL, array(), t('Remove')); // Test if the page resolves and there is something in the cart. - $this->assertText(t('Your shopping cart is empty.'), t('Removed product and cart is empty')); + $this->assertText(t('Your shopping cart is empty.'), 'Removed product and cart is empty'); } } @@ -241,13 +241,13 @@ class CommerceCartTestCaseMultiProducts extends CommerceCartTestCase { } // Check if the selector exists. - $this->assertField('edit-product-id', t('The selector of products exists')); + $this->assertField('edit-product-id', 'The selector of products exists'); // Check if the products actually are present in the selector. - $this->assertTrue($this->product_titles == $option_titles, t('Correct products are present in the selector')); + $this->assertTrue($this->product_titles == $option_titles, 'Correct products are present in the selector'); // Look for the Add to cart button. - $this->assertField('edit-submit', t('Add to cart button exists')); + $this->assertField('edit-submit', 'Add to cart button exists'); } /** @@ -257,15 +257,15 @@ class CommerceCartTestCaseMultiProducts extends CommerceCartTestCase { public function testCommerceCartSelectProductAdd() { // Ensure the add to cart message is displayed. $message = t('%title added to your cart.', array('%title' => $this->product_titles[1], '!cart-url' => url('cart'))); - $this->assertRaw($message, t('Product add to cart message displayed.')); + $this->assertRaw($message, 'Product add to cart message displayed.'); // Go to cart url. $this->drupalGet($this->getCommerceUrl('cart')); // Test if the page resolves and there is something in the cart. $this->assertResponse(200); - $this->assertNoText(t('Your shopping cart is empty.'), t('Cart is not empty')); - $this->assertText($this->product_titles[1], t('Product was added to the cart')); + $this->assertNoText(t('Your shopping cart is empty.'), 'Cart is not empty'); + $this->assertText($this->product_titles[1], 'Product was added to the cart'); } /** @@ -278,15 +278,15 @@ class CommerceCartTestCaseMultiProducts extends CommerceCartTestCase { $this->drupalGet($this->getCommerceUrl('cart')); // Check remove button. - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-delete')]", NULL, t('Remove button present')); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-delete')]", NULL, 'Remove button present'); // Check quantity field. - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", NULL, t('Quantity field present')); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", 1, t('Quantity field has correct number of items')); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", NULL, 'Quantity field present'); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-edit-quantity')]", 1, 'Quantity field has correct number of items'); // Check if the Update cart and Checkout buttons are present. - $this->assertField("edit-submit", t('Update cart button present')); - $this->assertField("edit-checkout", t('Checkout button present')); + $this->assertField("edit-submit", 'Update cart button present'); + $this->assertField("edit-checkout", 'Checkout button present'); } /** @@ -298,7 +298,7 @@ class CommerceCartTestCaseMultiProducts extends CommerceCartTestCase { $order = commerce_cart_order_load($this->store_customer->uid); // Check if the user has at least one order in cart status. - $this->assertTrue(commerce_cart_order_is_cart($order), t('User has currently an order in cart status.')); + $this->assertTrue(commerce_cart_order_is_cart($order), 'User has currently an order in cart status.'); // Get the products out of the order and store them in an array. foreach (entity_metadata_wrapper('commerce_order', $order)->commerce_line_items as $delta => $line_item_wrapper) { @@ -309,7 +309,7 @@ class CommerceCartTestCaseMultiProducts extends CommerceCartTestCase { } // Check if the product is in the products array for the order. - $this->assertTrue(in_array($this->products[2]->product_id, array_keys($products_in_cart)), t('Product is actually in the cart')); + $this->assertTrue(in_array($this->products[2]->product_id, array_keys($products_in_cart)), 'Product is actually in the cart'); } } @@ -422,15 +422,15 @@ class CommerceCartTestCaseAttributes extends CommerceCartTestCase { // Ensure the add to cart message is displayed. $message = t('%title added to your cart.', array('%title' => 'field_1_value_2_field_2_value_1', '!cart-url' => url('cart'))); - $this->assertRaw($message, t('Product add to cart message displayed.')); + $this->assertRaw($message, 'Product add to cart message displayed.'); // Go to cart url. $this->drupalGet($this->getCommerceUrl('cart')); // Test if the page resolves and there is something in the cart. $this->assertResponse(200); - $this->assertNoText(t('Your shopping cart is empty.'), t('Cart is not empty')); - $this->assertText('field_1_value_2_field_2_value_1', t('Product was added to the cart')); + $this->assertNoText(t('Your shopping cart is empty.'), 'Cart is not empty'); + $this->assertText('field_1_value_2_field_2_value_1', 'Product was added to the cart'); } @@ -440,17 +440,17 @@ class CommerceCartTestCaseAttributes extends CommerceCartTestCase { public function testCommerceCartProductFormStructure() { $this->drupalGet('node/' . $this->product_node->nid); // Check whether the attribute selectors exist. - $this->assertField('edit-attributes-field-1', t('First attribute selector exists')); - $this->assertField('edit-attributes-field-2', t('Second attribute selector exists')); + $this->assertField('edit-attributes-field-1', 'First attribute selector exists'); + $this->assertField('edit-attributes-field-2', 'Second attribute selector exists'); // Check the number of attributes. $options = $this->xpath("//select[@id='edit-attributes-field-1']//option"); - $this->assertEqual(count($options), count($this->fields['field_1']['settings']['allowed_values']), t('Number of options for first attribute match')); + $this->assertEqual(count($options), count($this->fields['field_1']['settings']['allowed_values']), 'Number of options for first attribute match'); $options = $this->xpath("//select[@id='edit-attributes-field-2']//option"); - $this->assertEqual(count($options), count($this->fields['field_2']['settings']['allowed_values']), t('Number of options for second attribute match')); + $this->assertEqual(count($options), count($this->fields['field_2']['settings']['allowed_values']), 'Number of options for second attribute match'); // Look for the Add to cart button. - $this->assertField('edit-submit', t('Add to cart button exists')); + $this->assertField('edit-submit', 'Add to cart button exists'); } } @@ -516,8 +516,8 @@ class CommerceCartTestCaseAnonymousToAuthenticated extends CommerceCartTestCase // Access to the cart and check if the product is in it. $this->drupalGet($this->getCommerceUrl('cart')); - $this->assertNoText(t('Your shopping cart is empty.'), t('Cart is not empty')); - $this->assertText($this->product->title, t('Product was added to the cart')); + $this->assertNoText(t('Your shopping cart is empty.'), 'Cart is not empty'); + $this->assertText($this->product->title, 'Product was added to the cart'); // Change the price to check if the amount gets updated when the user logs // in. @@ -537,12 +537,12 @@ class CommerceCartTestCaseAnonymousToAuthenticated extends CommerceCartTestCase // Access to the cart and check if the product is in it. $this->drupalGet($this->getCommerceUrl('cart')); - $this->assertNoText(t('Your shopping cart is empty.'), t('Cart is not empty')); - $this->assertText($this->product->title, t('Product is still in the cart')); - $this->assertText(trim(commerce_currency_amount_to_decimal($this->product->commerce_price[LANGUAGE_NONE][0]['amount'], $this->product->commerce_price[LANGUAGE_NONE][0]['currency_code'])), t('Product price has been updated')); + $this->assertNoText(t('Your shopping cart is empty.'), 'Cart is not empty'); + $this->assertText($this->product->title, 'Product is still in the cart'); + $this->assertText(trim(commerce_currency_amount_to_decimal($this->product->commerce_price[LANGUAGE_NONE][0]['amount'], $this->product->commerce_price[LANGUAGE_NONE][0]['currency_code'])), 'Product price has been updated'); // Check if the order is the same. - $this->assertTrue($order_anonymous->order_id == $order_authenticated->order_id, t('Cart has been converted successfully')); + $this->assertTrue($order_anonymous->order_id == $order_authenticated->order_id, 'Cart has been converted successfully'); } } diff --git a/modules/checkout/tests/commerce_checkout.test b/modules/checkout/tests/commerce_checkout.test index 56351cca..ac30d47a 100644 --- a/modules/checkout/tests/commerce_checkout.test +++ b/modules/checkout/tests/commerce_checkout.test @@ -90,21 +90,21 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $this->drupalLogin($this->store_customer); // Access to the config page for checkout forms $this->drupalGet('admin/commerce/config/checkout/form'); - $this->assertResponse(403, t('A normal user is not able to access to the checkout configuration form page.')); + $this->assertResponse(403, 'A normal user is not able to access to the checkout configuration form page.'); // Log in as store admin. $this->drupalLogin($this->store_admin); // Access to the config page for checkout forms. $this->drupalGet('admin/commerce/config/checkout/form'); - $this->assertResponse(200, t('Store admin can access to the checkout configuration form page.')); + $this->assertResponse(200, 'Store admin can access to the checkout configuration form page.'); // Modify weight of the panes $this->drupalPost('admin/commerce/config/checkout/form', array('panes[cart_contents][weight]'=> 1), t('Save configuration')); - $this->assertOptionSelected('edit-panes-cart-contents-weight', 1, t('Pane weight changed')); + $this->assertOptionSelected('edit-panes-cart-contents-weight', 1, 'Pane weight changed'); // Change one pane to other page $this->drupalPost('admin/commerce/config/checkout/form', array('panes[checkout_review][page]'=> 'disabled'), t('Save configuration')); - $this->assertOptionSelected('edit-panes-checkout-review-page', 'disabled', t('Pane page changed')); + $this->assertOptionSelected('edit-panes-checkout-review-page', 'disabled', 'Pane page changed'); } /** @@ -121,14 +121,14 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $this->drupalGet($this->getCommerceUrl('checkout')); // Check if the page resolves and if the default panes are present. - $this->assertResponse(200, t('The owner of the order can access to the checkout page')); - $this->assertTitle(t('Checkout') . ' | Drupal', t('Title of the checkout phase is correct')); - $this->assertText(t('Shopping cart contents'), t('Shopping cart contents pane is present')); - $this->assertText(t('Billing information'), t('Billing information pane is present')); + $this->assertResponse(200, 'The owner of the order can access to the checkout page'); + $this->assertTitle(t('Checkout') . ' | Drupal', 'Title of the checkout phase is correct'); + $this->assertText(t('Shopping cart contents'), 'Shopping cart contents pane is present'); + $this->assertText(t('Billing information'), 'Billing information pane is present'); // We are testing with authenticated user, so no account information // should appear. - $this->assertNoText(t('Account information'), t('Account information pane is not present')); + $this->assertNoText(t('Account information'), 'Account information pane is not present'); // Generate random information, as city, postal code, etc. $address_info = $this->generateAddressInformation(); @@ -139,7 +139,7 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { // Check if the country has been selected correctly, this uses XPath as the // ajax call replaces the element and the id may change. - $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', t('Country selected')); + $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', 'Country selected'); // Fill in the required information for billing pane, with a random State. $info = array( @@ -153,13 +153,13 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { // Check for default panes and information in this checkout phase. $this->pass(t('Checking the default panes and the page information:')); - $this->assertTitle(t('Review order') . ' | Drupal', t('Title of the checkout phase \'Review order\' is correct')); - $this->assertText($address_info['name_line'], t('Billing information for \'name_line\' is correct')); - $this->assertText($address_info['thoroughfare'], t('Billing information for \'thoroughfare\' is correct')); - $this->assertText($address_info['locality'], t('Billing information for \'locality\' is correct')); - $this->assertText(trim($address_info['postal_code']), t('Billing information for \'postal_code\' is correct')); - $this->assertText('United States', t('Billing information country is correct')); - $this->assertText('Example payment', t('Example payment method pane is present')); + $this->assertTitle(t('Review order') . ' | Drupal', 'Title of the checkout phase \'Review order\' is correct'); + $this->assertText($address_info['name_line'], 'Billing information for \'name_line\' is correct'); + $this->assertText($address_info['thoroughfare'], 'Billing information for \'thoroughfare\' is correct'); + $this->assertText($address_info['locality'], 'Billing information for \'locality\' is correct'); + $this->assertText(trim($address_info['postal_code']), 'Billing information for \'postal_code\' is correct'); + $this->assertText('United States', 'Billing information country is correct'); + $this->assertText('Example payment', 'Example payment method pane is present'); // Load the order to check the status. $order = commerce_order_load_multiple(array($this->order->order_id), array(), TRUE); @@ -167,13 +167,13 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { entity_get_controller('commerce_order')->resetCache(); // At this point we should be in Checkout Review. - $this->assertEqual(reset($order)->status, 'checkout_review', t('Order status is \'Checkout Review\' in the review phase.')); + $this->assertEqual(reset($order)->status, 'checkout_review', 'Order status is \'Checkout Review\' in the review phase.'); // Test the back & continue buttons. $this->drupalPost(NULL, array(), t('Go back')); - $this->assertTitle(t('Checkout') . ' | Drupal', t('When clicking in the \'Back\' button, the title displayed corresponds with the current checkout phase: \'Checkout\'')); + $this->assertTitle(t('Checkout') . ' | Drupal', 'When clicking in the \'Back\' button, the title displayed corresponds with the current checkout phase: \'Checkout\''); $this->drupalPost(NULL, array(), t('Continue to next step')); - $this->assertTitle(t('Review order') . ' | Drupal', t('When clicking in the \'Continue\' button, the title displayed corresponds with the current checkout phase: \'Review order\'')); + $this->assertTitle(t('Review order') . ' | Drupal', 'When clicking in the \'Continue\' button, the title displayed corresponds with the current checkout phase: \'Review order\''); // Finish checkout process $this->drupalPost(NULL, array(), t('Continue to next step')); @@ -182,10 +182,10 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $order = commerce_order_load_multiple(array($this->order->order_id), array(), TRUE); // Order status should be pending when completing checkout process. - $this->assertEqual(reset($order)->status, 'pending', t('Order status is \'Pending\' after completing checkout')); + $this->assertEqual(reset($order)->status, 'pending', 'Order status is \'Pending\' after completing checkout'); // Check if the completion message has been displayed. - $this->assertTitle(t('Checkout complete') . ' | Drupal', t('Title of the page is \'Checkout complete\' when finishing the checkout process')); - $this->assertText(t('Your order number is @order-number.', array('@order-number' => $this->order->order_number)), t('Completion message for the checkout is correctly displayed')); + $this->assertTitle(t('Checkout complete') . ' | Drupal', 'Title of the page is \'Checkout complete\' when finishing the checkout process'); + $this->assertText(t('Your order number is @order-number.', array('@order-number' => $this->order->order_number)), 'Completion message for the checkout is correctly displayed'); } /** @@ -198,8 +198,8 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $this->drupalGet($this->getCommerceUrl('checkout')); // Test billing information and account information panes. - $this->assertText(t('Billing information'), t('Billing information pane is present in the checkout page')); - $this->assertText(t('Account information'), t('Account information pane is present in the checkout page')); + $this->assertText(t('Billing information'), 'Billing information pane is present in the checkout page'); + $this->assertText(t('Account information'), 'Account information pane is present in the checkout page'); // Test validation messages not filling any information. $this->drupalPost(NULL, array(), t('Continue to next step')); @@ -213,7 +213,7 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { foreach (element_children($pane_form['commerce_customer_address'][LANGUAGE_NONE][0]) as $key) { $element = $pane_form['commerce_customer_address'][LANGUAGE_NONE][0][$key]; if ($element['#required'] && empty($element['#default_value'])) { - $this->assertText(t('!pane_message field is required', array('!pane_message' => $element['#title'])), t('Check required billing information pane messages')); + $this->assertText(t('!pane_message field is required', array('!pane_message' => $element['#title'])), 'Check required billing information pane messages'); } } @@ -222,7 +222,7 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $pane_form = drupal_get_form($callback, $panes['account'], $this->order); foreach (element_children($pane_form['login']) as $key) { if ($pane_form['login'][$key]['#required']) { - $this->assertText(t('!pane_message field is required', array('!pane_message' => $pane_form['login'][$key]['#title'])), t('Check required account pane message.')); + $this->assertText(t('!pane_message field is required', array('!pane_message' => $pane_form['login'][$key]['#title'])), 'Check required account pane message.'); } } @@ -254,14 +254,14 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $this->drupalPost(NULL, $info, t('Continue to next step')); // Check if the wrong e-mail address fails validation. - $this->assertRaw(t('The e-mail address %mail is not valid.', array('%mail' => $user_mail)), t('A warning message is displayed when the e-mail address for the anonymous user is not valid')); + $this->assertRaw(t('The e-mail address %mail is not valid.', array('%mail' => $user_mail)), 'A warning message is displayed when the e-mail address for the anonymous user is not valid'); // Fix it and continue to next step. $user_mail = $this->randomName() . '@example.com'; $info['account[login][mail]'] = $user_mail; $this->drupalPost(NULL, $info, t('Continue to next step')); - $this->assertNoRaw(t('The e-mail address %mail is not valid.', array('%mail' => $user_mail)), t('A warning message is not displayed when the e-mail address for the anonymous user is valid')); + $this->assertNoRaw(t('The e-mail address %mail is not valid.', array('%mail' => $user_mail)), 'A warning message is not displayed when the e-mail address for the anonymous user is valid'); // Finish checkout process for good. $this->drupalPost(NULL, array(), t('Continue to next step')); @@ -277,11 +277,11 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $this->drupalGet($this->getCommerceUrl('checkout')); // Check if the page resolves and if the default panes are present - $this->assertResponse(200, t('Anonymous user can access to the checkout page for the order.')); - $this->assertTitle(t('Checkout') . ' | Drupal', t('Title of the checkout phase is correct')); - $this->assertText(t('Shopping cart contents'), t('Shopping cart contents pane is present')); - $this->assertText(t('Billing information'), t('Billing information pane is present')); - $this->assertText(t('Account information'), t('Account information pane is present')); + $this->assertResponse(200, 'Anonymous user can access to the checkout page for the order.'); + $this->assertTitle(t('Checkout') . ' | Drupal', 'Title of the checkout phase is correct'); + $this->assertText(t('Shopping cart contents'), 'Shopping cart contents pane is present'); + $this->assertText(t('Billing information'), 'Billing information pane is present'); + $this->assertText(t('Account information'), 'Account information pane is present'); // Generate random information, as user mail, city, etc. $user_mail = $this->randomName() . '@example.com'; @@ -293,7 +293,7 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { // Check if the country has been selected correctly, this uses XPath as the // ajax call replaces the element and the id may change - $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', t('Country selected')); + $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', 'Country selected'); // Fill in the required information for billing pane, with a random State. $info = array( @@ -314,14 +314,14 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { // Check for default panes and information in this checkout phase. $this->pass(t('Checking the default panes and the page information:')); - $this->assertTitle(t('Review order') . ' | Drupal', t('Title of the checkout phase \'Review order\' is correct')); - $this->assertText($address_info['name_line'], t('Billing information for \'name_line\' is correct')); - $this->assertText($address_info['thoroughfare'], t('Billing information for \'thoroughfare\' is correct')); - $this->assertText($address_info['locality'], t('Billing information for \'locality\' is correct')); - $this->assertText(trim($address_info['postal_code']), t('Billing information for \'postal_code\' is correct')); - $this->assertText('United States', t('Billing information country is correct')); - $this->assertText('Example payment', t('Example payment method pane is present')); - $this->assertText($user_mail, t('Account information is correct')); + $this->assertTitle(t('Review order') . ' | Drupal', 'Title of the checkout phase \'Review order\' is correct'); + $this->assertText($address_info['name_line'], 'Billing information for \'name_line\' is correct'); + $this->assertText($address_info['thoroughfare'], 'Billing information for \'thoroughfare\' is correct'); + $this->assertText($address_info['locality'], 'Billing information for \'locality\' is correct'); + $this->assertText(trim($address_info['postal_code']), 'Billing information for \'postal_code\' is correct'); + $this->assertText('United States', 'Billing information country is correct'); + $this->assertText('Example payment', 'Example payment method pane is present'); + $this->assertText($user_mail, 'Account information is correct'); // Load the order to check the status. $order = commerce_order_load_multiple(array($this->order->order_id), array(), TRUE); @@ -329,7 +329,7 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { entity_get_controller('commerce_order')->resetCache(); // At this point we should be in Checkout Review. - $this->assertEqual(reset($order)->status, 'checkout_review', t('Order status is \'Checkout Review\' in the review phase.')); + $this->assertEqual(reset($order)->status, 'checkout_review', 'Order status is \'Checkout Review\' in the review phase.'); // Finish checkout process $this->drupalPost(NULL, array(), t('Continue to next step')); @@ -338,12 +338,12 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $order = commerce_order_load_multiple(array($this->order->order_id), array(), TRUE); // Order status should be pending when completing checkout process. - $this->assertEqual(reset($order)->status, 'pending', t('Order status is \'Pending\' after completing checkout.')); + $this->assertEqual(reset($order)->status, 'pending', 'Order status is \'Pending\' after completing checkout.'); // Check if the completion message has been displayed. - $this->assertTitle(t('Checkout complete') . ' | Drupal', t('Title of the page is \'Checkout complete\' when finishing the checkout process')); + $this->assertTitle(t('Checkout complete') . ' | Drupal', 'Title of the page is \'Checkout complete\' when finishing the checkout process'); // Check completion message. - $this->assertText(t('Your order number is @order-number.', array('@order-number' => $this->order->order_number)), t('Completion message for the checkout is correctly displayed')); + $this->assertText(t('Your order number is @order-number.', array('@order-number' => $this->order->order_number)), 'Completion message for the checkout is correctly displayed'); } /** @@ -388,7 +388,7 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { $order = commerce_order_load_multiple(array($this->order->order_id), array(), TRUE); // Assert that the owner of the order is the owner of the e-mail address used. - $this->assertEqual($this->store_customer->uid, reset($order)->uid, t('The order has been correctly assigned to the user owner of the mail address')); + $this->assertEqual($this->store_customer->uid, reset($order)->uid, 'The order has been correctly assigned to the user owner of the mail address'); } /** @@ -435,8 +435,8 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { // Check if the order completion triggered the user creation rule. $user = user_load(reset($order)->uid); - $this->assertEqual($user->mail, $user_mail, t('The e-mail address of the owner of the order matches the one in the checkout input')); - $this->assertTrue($this->store_customer->uid < $user->uid, t('User id of the new user is higher than the last user created then it is a new account')); + $this->assertEqual($user->mail, $user_mail, 'The e-mail address of the owner of the order matches the one in the checkout input'); + $this->assertTrue($this->store_customer->uid < $user->uid, 'User id of the new user is higher than the last user created then it is a new account'); } /** @@ -495,7 +495,7 @@ class CommerceCheckoutTestProcess extends CommerceBaseTestCase { // Check if the country has been selected correctly, this uses XPath as the // ajax call replaces the element and the id may change - $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', t('Country selected')); + $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', 'Country selected'); // Fill in the required information for billing pane, with a random State. $info = array( diff --git a/modules/customer/tests/commerce_customer_ui.test b/modules/customer/tests/commerce_customer_ui.test index c2db3655..30a3847e 100644 --- a/modules/customer/tests/commerce_customer_ui.test +++ b/modules/customer/tests/commerce_customer_ui.test @@ -61,18 +61,18 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $this->drupalLogin($this->store_customer); // Check the access to the profiles listing. $this->drupalGet('admin/commerce/customer-profiles'); - $this->assertResponse(403, t('The store customer has no access to the administration listing of customer profiles')); + $this->assertResponse(403, 'The store customer has no access to the administration listing of customer profiles'); // Login with store admin. $this->drupalLogin($this->store_admin); // Check the access to the profiles listing. $this->drupalGet('admin/commerce/customer-profiles'); - $this->assertResponse(200, t('The store customer has access to the administration listing of customer profiles')); + $this->assertResponse(200, 'The store customer has access to the administration listing of customer profiles'); // Check the message of no profiles available. - $this->assertText(t('No customer profiles have been created yet.'), t('\'No customer profiles have been created yet\' message is displayed')); + $this->assertText(t('No customer profiles have been created yet.'), '\'No customer profiles have been created yet\' message is displayed'); // Check the add customer profile link. - $this->assertRaw(l('Add a customer profile', 'admin/commerce/customer-profiles/add'), t('\'Add a customer profile\' link is present in the page')); + $this->assertRaw(l('Add a customer profile', 'admin/commerce/customer-profiles/add'), '\'Add a customer profile\' link is present in the page'); } /** @@ -83,13 +83,13 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $this->drupalLogin($this->store_customer); // Check the access to the profile types listing. $this->drupalGet('admin/commerce/customer-profiles/types'); - $this->assertResponse(403, t('The store customer has no access to the administration listing of customer profile types')); + $this->assertResponse(403, 'The store customer has no access to the administration listing of customer profile types'); // Login with store admin. $this->drupalLogin($this->store_admin); // Check the access to the profile types listing. $this->drupalGet('admin/commerce/customer-profiles/types'); - $this->assertResponse(200, t('The store customer has access to the administration listing of customer profile types')); + $this->assertResponse(200, 'The store customer has access to the administration listing of customer profile types'); // Check if all the profiles defined by default are there. $types = commerce_customer_profile_types(); @@ -127,13 +127,13 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $billing_country = $this->xpath("//select[starts-with(@name, 'commerce_customer_address')]"); $this->drupalPostAJAX(NULL, array((string) $billing_country[0]['name'] => $address['country']), (string) $billing_country[0]['name']); - $this->assertFieldByXPath("//select[starts-with(@id, 'edit-commerce-customer-address-und-0-country')]", $address['country'], t('Country field exists and it has the default country selected')); + $this->assertFieldByXPath("//select[starts-with(@id, 'edit-commerce-customer-address-und-0-country')]", $address['country'], 'Country field exists and it has the default country selected'); $this->assertFieldByXPath("//input[starts-with(@id, 'edit-commerce-customer-address-und-0-name-line')]", NULL, t('Field !field exists in the customer profile form', array('!field' => 'Name line'))); // Also check for the buttons and cancel link. - $this->assertFieldById('edit-submit', t('Save profile'), t('\'Save profile\' button is present')); - $this->assertFieldById('edit-save-continue', t('Save and add another'), t('\'Save an add another\' button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/customer-profiles'), t('Cancel link is present')); + $this->assertFieldById('edit-submit', t('Save profile'), '\'Save profile\' button is present'); + $this->assertFieldById('edit-save-continue', t('Save and add another'), '\'Save an add another\' button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/customer-profiles'), 'Cancel link is present'); // Generate random information, as city, postal code, etc. $address_info = $this->generateAddressInformation(); @@ -158,11 +158,11 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { ); } $profile = $this->loadCustomerProfile($conditions); - $this->assertFalse(empty($profile), t('Profile has been created in database')); + $this->assertFalse(empty($profile), 'Profile has been created in database'); // Check the landing url and if the profile is in the listing. - $this->assertTrue($this->url == url('admin/commerce/customer-profiles', array('absolute' => TRUE)), t('Landing page after save the profile is the profile listing page')); - $this->assertText(t('Profile saved'), t('\'Profile saved\' message is displayed after saving a customer profile')); + $this->assertTrue($this->url == url('admin/commerce/customer-profiles', array('absolute' => TRUE)), 'Landing page after save the profile is the profile listing page'); + $this->assertText(t('Profile saved'), '\'Profile saved\' message is displayed after saving a customer profile'); $this->assertText($address_info['name_line'], t('Profile name line value: !value is present in the customer profile listing', array('!value' => $address_info['name_line']))); } @@ -193,9 +193,9 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $this->drupalPost(NULL, $info, t('Save and add another')); // Check the landing url and if the profile got created. - $this->assertTrue($this->url == url('admin/commerce/customer-profiles/add/billing', array('absolute' => TRUE)), t('Landing page after save and add another for profiles is the profile creation page')); - $this->assertText(t('Profile saved'), t('\'Profile saved\' message is displayed after saving a customer profile')); - $this->assertFieldById('edit-commerce-customer-address-und-0-name-line', '', t('\'Name line\' field is present and empty')); + $this->assertTrue($this->url == url('admin/commerce/customer-profiles/add/billing', array('absolute' => TRUE)), 'Landing page after save and add another for profiles is the profile creation page'); + $this->assertText(t('Profile saved'), '\'Profile saved\' message is displayed after saving a customer profile'); + $this->assertFieldById('edit-commerce-customer-address-und-0-name-line', '', '\'Name line\' field is present and empty'); $conditions = array(); foreach ($address_info as $id => $element) { @@ -206,7 +206,7 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { ); } $profile = $this->loadCustomerProfile($conditions); - $this->assertFalse(empty($profile), t('Profile has been created in database')); + $this->assertFalse(empty($profile), 'Profile has been created in database'); } @@ -218,7 +218,7 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $this->drupalLogin($this->store_admin); // Access to the profile billing type manage fields. $this->drupalGet('admin/commerce/customer-profiles/types/billing/fields'); - $this->assertResponse(200, t('Store admin user is able to access the customer profile type manage fields screen')); + $this->assertResponse(200, 'Store admin user is able to access the customer profile type manage fields screen'); // Create an extra field for the profile. $edit = array( @@ -253,7 +253,7 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $this->drupalPost(NULL, $info, t('Save profile')); // Check that the profile got created and if the field is filled. - $this->assertText(t('Profile saved'), t('\'Profile saved\' message is displayed after saving a customer profile')); + $this->assertText(t('Profile saved'), '\'Profile saved\' message is displayed after saving a customer profile'); // Check also in database. foreach ($address_info as $id => $element) { @@ -284,12 +284,12 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $address = $profile->commerce_customer_address[LANGUAGE_NONE][0]; // Check the integrity of the edit form. $this->pass(t('Test the integrity of the edit customer profile form:')); - $this->assertFieldById('edit-commerce-customer-address-und-0-country', $address['country'], t('Country field exists and it has the default country selected')); + $this->assertFieldById('edit-commerce-customer-address-und-0-country', $address['country'], 'Country field exists and it has the default country selected'); $this->assertFieldById('edit-commerce-customer-address-und-0-name-line', $address['name_line'], t('Field !field exists in the customer profile form and has the correct value !value', array('!field' => 'Name line', '!value' => $address['name_line']))); // Also check for the buttons and cancel link. - $this->assertFieldById('edit-submit', t('Save profile'), t('\'Save profile\' button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/customer-profiles'), t('Cancel link is present')); + $this->assertFieldById('edit-submit', t('Save profile'), '\'Save profile\' button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/customer-profiles'), 'Cancel link is present'); // Change some fields and save. $edit = array( @@ -301,18 +301,18 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { // Assert fields after saving the profile. $this->pass(t('Assert the field values after saving the profile form:')); - $this->assertTrue($this->url == url('admin/commerce/customer-profiles/'. $profile->profile_id .'/edit', array('absolute' => TRUE)), t('Landing page after save the profile is the profile edit page')); - $this->assertText(t('Profile saved'), t('\'Profile saved\' message is displayed after saving a customer profile')); + $this->assertTrue($this->url == url('admin/commerce/customer-profiles/'. $profile->profile_id .'/edit', array('absolute' => TRUE)), 'Landing page after save the profile is the profile edit page'); + $this->assertText(t('Profile saved'), '\'Profile saved\' message is displayed after saving a customer profile'); $this->assertFieldById('edit-commerce-customer-address-und-0-name-line', $edit['commerce_customer_address[und][0][name_line]'], t('Field !field exists in the customer profile form and has the correct value !value', array('!field' => 'Name line', '!value' => $edit['commerce_customer_address[und][0][name_line]']))); $this->assertFieldById('edit-commerce-customer-address-und-0-locality', $edit['commerce_customer_address[und][0][locality]'], t('Field !field exists in the customer profile form and has the correct value !value', array('!field' => 'Locality', '!value' => $edit['commerce_customer_address[und][0][locality]']))); - $this->assertFieldByName('name', NULL, t('Name field is present and empty')); + $this->assertFieldByName('name', NULL, 'Name field is present and empty'); // Check at database level. $profiles = commerce_customer_profile_load_multiple(array($profile->profile_id), array(), TRUE); $profile = reset($profiles); - $this->assertTrue($profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'] == $edit['commerce_customer_address[und][0][name_line]'], t('\'Name line\' field has been correctly modified in the customer profile')); - $this->assertTrue($profile->commerce_customer_address[LANGUAGE_NONE][0]['locality'] == $edit['commerce_customer_address[und][0][locality]'], t('\'Locality\' field has been correctly modified in the customer profile')); - $this->assertTrue($profile->uid == 0, t('Profile owner is now anonymous user')); + $this->assertTrue($profile->commerce_customer_address[LANGUAGE_NONE][0]['name_line'] == $edit['commerce_customer_address[und][0][name_line]'], '\'Name line\' field has been correctly modified in the customer profile'); + $this->assertTrue($profile->commerce_customer_address[LANGUAGE_NONE][0]['locality'] == $edit['commerce_customer_address[und][0][locality]'], '\'Locality\' field has been correctly modified in the customer profile'); + $this->assertTrue($profile->uid == 0, 'Profile owner is now anonymous user'); } /** @@ -329,10 +329,10 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $this->drupalPost('admin/commerce/customer-profiles/'. $profile->profile_id .'/edit', array('status' => 0), t('Save profile')); $this->drupalGet('admin/commerce/customer-profiles'); - $this->assertText(t('Disabled'), t('\'Disabled\' text for the profile appears in the profile listing page')); + $this->assertText(t('Disabled'), '\'Disabled\' text for the profile appears in the profile listing page'); $profiles = commerce_customer_profile_load_multiple(array($profile->profile_id), array(), TRUE); $profile = reset($profiles); - $this->assertTrue($profile->status == 0, t('Profile status is Disabled')); + $this->assertTrue($profile->status == 0, 'Profile status is Disabled'); } /** @@ -345,33 +345,33 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $this->drupalLogin($this->store_customer); // Check the access to the profile delete. $this->drupalGet('admin/commerce/customer-profiles/'. $profile->profile_id .'/delete'); - $this->assertResponse(403, t('Store customer is not able to access the admin deletion page for a customer profile')); + $this->assertResponse(403, 'Store customer is not able to access the admin deletion page for a customer profile'); // Login with store admin. $this->drupalLogin($this->store_admin); // Check the access to the profile delete. $this->drupalGet('admin/commerce/customer-profiles/'. $profile->profile_id .'/delete'); - $this->assertResponse(200, t('Store customer is able to access the admin deletion page for a customer profile')); + $this->assertResponse(200, 'Store customer is able to access the admin deletion page for a customer profile'); // Check the integrity of the delete form. $this->pass(t('Test the integrity of the delete customer profile form:')); - $this->assertTitle(t('Are you sure you want to delete this profile?') . ' | Drupal', t('The title of the deletion page is correct')); - $this->assertText(t('Deleting this profile cannot be undone'), t('A warning message for deleting the profile is displayed')); + $this->assertTitle(t('Are you sure you want to delete this profile?') . ' | Drupal', 'The title of the deletion page is correct'); + $this->assertText(t('Deleting this profile cannot be undone'), 'A warning message for deleting the profile is displayed'); $this->assertFieldById('edit-submit', t('Delete'), '\'Delete\' button is present'); - $this->assertLink(t('Cancel'), 0, t('Cancel link is present')); + $this->assertLink(t('Cancel'), 0, 'Cancel link is present'); // Delete the profile. $this->drupalPost(NULL, array(), t('Delete')); // Assert the landing page and confirmation messages. - $this->assertTrue($this->url == url('admin/commerce/customer-profiles', array('absolute' => TRUE)), t('Landing page after deleting the profile is the profile listing page')); - $this->assertText(t('The profile has been deleted'), t('Confirmation message after deleting the profile is displayed')); - $this->assertText(t('No customer profiles have been created yet.'), t('\'No customer profiles have been created yet\' message is displayed')); + $this->assertTrue($this->url == url('admin/commerce/customer-profiles', array('absolute' => TRUE)), 'Landing page after deleting the profile is the profile listing page'); + $this->assertText(t('The profile has been deleted'), 'Confirmation message after deleting the profile is displayed'); + $this->assertText(t('No customer profiles have been created yet.'), '\'No customer profiles have been created yet\' message is displayed'); // Check at database level. $profiles = commerce_customer_profile_load_multiple(array($profile->profile_id), array(), TRUE); $profile = reset($profiles); - $this->assertTrue(empty($profile), t('Profile can\'t be loaded from database after deleting it')); + $this->assertTrue(empty($profile), 'Profile can\'t be loaded from database after deleting it'); } /** @@ -400,7 +400,7 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { // Check if the country has been selected correctly, this uses XPath as the // ajax call replaces the element and the id may change - $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', t('Country selected')); + $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', 'Country selected'); // Fill in the required information for billing pane, with a random State. $info = array( @@ -426,7 +426,7 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile); $address = $profile_wrapper->commerce_customer_address->value(); - $this->assertTrue(array_intersect($address_info, $address) == $address_info, t('The address info for the checkout is stored in the customer profile')); + $this->assertTrue(array_intersect($address_info, $address) == $address_info, 'The address info for the checkout is stored in the customer profile'); // Check the customer profile in the listing. $this->drupalGet('admin/commerce/customer-profiles'); @@ -459,7 +459,7 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { ); $this->drupalPost(NULL, $info, t('Save order')); - $this->assertText(t('Order saved'), t('\'Order saved\' message is displayed')); + $this->assertText(t('Order saved'), '\'Order saved\' message is displayed'); // Check the customer profile in the listing. $this->drupalGet('admin/commerce/customer-profiles'); $this->assertTrue($address_info['name_line'], t('\'Name line\' text is present with the correct value: !value', array('!value' => $address_info['name_line']))); @@ -476,7 +476,7 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $profiles = $this->loadCustomerProfile($conditions); $profile = commerce_customer_profile_load(reset($profiles)->profile_id); $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile); - $this->assertFalse(empty($profile), t('Profile has been created in database')); + $this->assertFalse(empty($profile), 'Profile has been created in database'); foreach ($address_info as $name => $info) { $this->assertEqual($profile_wrapper->commerce_customer_address->{$name}->value(), $info, t('!name is present in the profile with value !value', array('!name' => $name, '!value' => $info))); } @@ -500,7 +500,7 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { ); $this->drupalPost('admin/commerce/orders/' . $order->order_id . '/edit', $edit, t('Save order')); - $this->assertText(t('Order saved'), t('\'Order saved\' message is displayed')); + $this->assertText(t('Order saved'), '\'Order saved\' message is displayed'); // Check the customer profile in the listing. $this->drupalGet('admin/commerce/customer-profiles'); $this->assertTrue($edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]'], t('\'Name line\' text is present with the correct value: !value', array('!value' => $edit['commerce_customer_billing[und][profiles][0][commerce_customer_address][und][0][name_line]']))); @@ -529,12 +529,12 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { // Check the customer profile is not present in the listing. $this->drupalGet('admin/commerce/customer-profiles'); - $this->assertNoText($profile_wrapper->commerce_customer_address->name_line->value(), t('\'Name line\' for the profile is not present in the customer profiles listing')); + $this->assertNoText($profile_wrapper->commerce_customer_address->name_line->value(), '\'Name line\' for the profile is not present in the customer profiles listing'); // Check the customer profile has been deleted at database level. $profiles = commerce_customer_profile_load_multiple(array($profile->profile_id), array(), TRUE); $profile = reset($profiles); - $this->assertTrue(empty($profile), t('Profile has been delete from database')); + $this->assertTrue(empty($profile), 'Profile has been delete from database'); } /** @@ -554,8 +554,8 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { // Check the customer profile has been deleted at database level. $profiles = commerce_customer_profile_load_multiple($profile_ids, array(), TRUE); - $this->assertTrue(!empty($profiles[$profile_with_order->profile_id]), t('Profile with order has not been delete from database')); - $this->assertTrue(empty($profiles[$profile_without_order->profile_id]), t('Profile without order has been delete from database')); + $this->assertTrue(!empty($profiles[$profile_with_order->profile_id]), 'Profile with order has not been delete from database'); + $this->assertTrue(empty($profiles[$profile_without_order->profile_id]), 'Profile without order has been delete from database'); } /** @@ -570,22 +570,22 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { // Check the customer profile types. $this->drupalGet('admin/commerce/customer-profiles/types'); - $this->assertText(t('Dummy profile type'), t('Dummy profile type is available in the profile types listing page')); + $this->assertText(t('Dummy profile type'), 'Dummy profile type is available in the profile types listing page'); // Check the order fields. $this->drupalGet('admin/commerce/config/order/fields'); - $this->assertText(t('Dummy profile type'), t('Dummy profile type is present in the order reference fields')); + $this->assertText(t('Dummy profile type'), 'Dummy profile type is present in the order reference fields'); // Check the checkout panes. $this->drupalGet('admin/commerce/config/checkout/form'); - $this->assertText(t('Dummy profile type'), t('Dummy profile type is present as checkout pane')); + $this->assertText(t('Dummy profile type'), 'Dummy profile type is present as checkout pane'); // Create an order for store customer. $order = $this->createDummyOrder($this->store_customer->uid, array(), 'pending'); // Check if the profile type is present. $this->drupalGet('admin/commerce/orders/' . $order->order_id . '/edit'); - $this->assertText(t('Dummy profile type'), t('Dummy profile type is present in the order edit form')); + $this->assertText(t('Dummy profile type'), 'Dummy profile type is present in the order edit form'); } /** @@ -658,6 +658,6 @@ class CommerceCustomerUITest extends CommerceBaseTestCase { $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile); $dummy_address = $profile_wrapper->commerce_customer_address->value(); - $this->assertTrue(array_intersect($billing_address, $dummy_address) == $billing_address, t('A billing information customer profile was successfully copied to a dummy customer profile during checkout.')); + $this->assertTrue(array_intersect($billing_address, $dummy_address) == $billing_address, 'A billing information customer profile was successfully copied to a dummy customer profile during checkout.'); } } diff --git a/modules/order/tests/commerce_order_ui.test b/modules/order/tests/commerce_order_ui.test index 9a023f78..8cf55c8b 100644 --- a/modules/order/tests/commerce_order_ui.test +++ b/modules/order/tests/commerce_order_ui.test @@ -75,9 +75,9 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { */ public function testCommerceOrderUICreateOrder() { // First, check if the order has been created in the database. - $this->assertTrue(is_object($this->order), t('Order has been created in database')); + $this->assertTrue(is_object($this->order), 'Order has been created in database'); // Also, the user owning the order should match. - $this->assertTrue($this->order->uid == $this->store_customer->uid, t('Order owner match')); + $this->assertTrue($this->order->uid == $this->store_customer->uid, 'Order owner match'); } /** @@ -89,14 +89,14 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the order edit page, it shouldn't be accessible. $this->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/edit'); - $this->assertResponse(403, t('Normal user is not able to access the order edit admin screen')); + $this->assertResponse(403, 'Normal user is not able to access the order edit admin screen'); // Log in as store admin. $this->drupalLogin($this->store_admin); // Access the edit page of the order. $this->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/edit'); - $this->assertResponse(200, t('Store admin user can access the order edit admin screen')); + $this->assertResponse(200, 'Store admin user can access the order edit admin screen'); // Update some values, like the owner of the order, datestamp, etc. $timestamp = REQUEST_TIME; @@ -117,17 +117,17 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Check the order properties. $this->pass(t('Order in database assertions:')); - $this->assertTrue($order_wrapper->uid->value() == 0, t('Order owner correctly updated')); - $this->assertTrue($order->log == $edit['log'], t('Order log correctly updated')); - $this->assertTrue($order_wrapper->created->value() == $timestamp, t('Order created date correctly updated')); - $this->assertTrue($order_wrapper->status->value() == $edit['status'], t('Order status correctly updated')); + $this->assertTrue($order_wrapper->uid->value() == 0, 'Order owner correctly updated'); + $this->assertTrue($order->log == $edit['log'], 'Order log correctly updated'); + $this->assertTrue($order_wrapper->created->value() == $timestamp, 'Order created date correctly updated'); + $this->assertTrue($order_wrapper->status->value() == $edit['status'], 'Order status correctly updated'); // Check if the values have been changed. Log is not checked because it // is a message for each revision. $this->pass(t('Order in screen assertions:')); - $this->assertFieldById('edit-name', $edit['name'], t('Name correctly modified')); - $this->assertFieldById('edit-date', $edit['date'], t('Date changed correctly')); - $this->assertOptionSelected('edit-status', $edit['status'], t('Status changed')); + $this->assertFieldById('edit-name', $edit['name'], 'Name correctly modified'); + $this->assertFieldById('edit-date', $edit['date'], 'Date changed correctly'); + $this->assertOptionSelected('edit-status', $edit['status'], 'Status changed'); } /** @@ -143,8 +143,8 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Add a product line item to the order. $this->drupalPostAJAX(NULL, array('commerce_line_items[und][actions][line_item_type]' => 'product'), array('op' => t('Add line item'))); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-commerce-line-items-und-actions-product-sku')]", NULL, t('Product select form is present in the order admin screen')); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-commerce-line-items-und-actions-save-line-item')]", NULL, t('Add product button is present in the order admin screen')); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-commerce-line-items-und-actions-product-sku')]", NULL, 'Product select form is present in the order admin screen'); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-commerce-line-items-und-actions-save-line-item')]", NULL, 'Add product button is present in the order admin screen'); $this->drupalPostAJAX(NULL, array('commerce_line_items[und][actions][product_sku]' => $this->product->sku), array('op' => t('Add product'))); $this->drupalPost(NULL, array(), t('Save order', array(), array('context' => 'a drupal commerce order'))); @@ -162,12 +162,12 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { $products[$product->product_id]= $product; } } - $this->assertTrue(in_array($this->product->product_id, array_keys($products)), t('Added product is included in the order at the database level')); + $this->assertTrue(in_array($this->product->product_id, array_keys($products)), 'Added product is included in the order at the database level'); // Access the edit page of the order and check if the product is present. $this->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/edit'); - $this->assertText($this->product->sku, t('SKU from product is present in the order edit screen')); - $this->assertText($this->product->title, t('Product title is present in the order edit screen')); + $this->assertText($this->product->sku, 'SKU from product is present in the order edit screen'); + $this->assertText($this->product->title, 'Product title is present in the order edit screen'); } /** @@ -205,9 +205,9 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Check the existance of the fields for quantity and price of the line // item just created. $this->pass(t('Check the existance of quantiy, price and currency code fields')); - $this->assertFieldById('edit-commerce-line-items-und-line-items-' . $line_item_id . '-quantity', 1, t('Quantity field is present and has value 1')); - $this->assertFieldById('edit-commerce-line-items-und-line-items-' . $line_item_id . '-commerce-unit-price-und-0-amount', $price, t('Price of the product is correct')); - $this->assertOptionSelected('edit-commerce-line-items-und-line-items-' . $line_item_id . '-commerce-unit-price-und-0-currency-code', $product_wrapper->commerce_price->currency_code->value(), t('Currency code is valid')); + $this->assertFieldById('edit-commerce-line-items-und-line-items-' . $line_item_id . '-quantity', 1, 'Quantity field is present and has value 1'); + $this->assertFieldById('edit-commerce-line-items-und-line-items-' . $line_item_id . '-commerce-unit-price-und-0-amount', $price, 'Price of the product is correct'); + $this->assertOptionSelected('edit-commerce-line-items-und-line-items-' . $line_item_id . '-commerce-unit-price-und-0-currency-code', $product_wrapper->commerce_price->currency_code->value(), 'Currency code is valid'); // Generate new quantity and prices and save them. $new_qty = rand(0,99); @@ -221,9 +221,9 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, $edit, t('Save order', array(), array('context' => 'a drupal commerce order'))); // Check if the modifications have been correctly done. - $this->assertFieldById('edit-commerce-line-items-und-line-items-' . $line_item_id . '-quantity', $new_qty, t('Quantity field has been correctly modified')); - $this->assertFieldById('edit-commerce-line-items-und-line-items-' . $line_item_id . '-commerce-unit-price-und-0-amount', $new_price, t('Price of the product has been correctly modified')); - $this->assertOptionSelected('edit-commerce-line-items-und-line-items-' . $line_item_id . '-commerce-unit-price-und-0-currency-code', $new_currency_code, t('Currency code has been correctly modified')); + $this->assertFieldById('edit-commerce-line-items-und-line-items-' . $line_item_id . '-quantity', $new_qty, 'Quantity field has been correctly modified'); + $this->assertFieldById('edit-commerce-line-items-und-line-items-' . $line_item_id . '-commerce-unit-price-und-0-amount', $new_price, 'Price of the product has been correctly modified'); + $this->assertOptionSelected('edit-commerce-line-items-und-line-items-' . $line_item_id . '-commerce-unit-price-und-0-currency-code', $new_currency_code, 'Currency code has been correctly modified'); } /** @@ -237,7 +237,7 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the order management page, it shouldn't be accessible. $this->drupalGet('admin/commerce/orders'); - $this->assertResponse(403, t('Normal user is not able to access the order admin screen')); + $this->assertResponse(403, 'Normal user is not able to access the order admin screen'); // Log in as store admin. $this->drupalLogin($this->store_admin); @@ -246,7 +246,7 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // really there. $this->drupalGet('admin/commerce/orders'); - $this->assertResponse(200, t('Store admin user can access the order admin screen')); + $this->assertResponse(200, 'Store admin user can access the order admin screen'); $this->pass(t('Order admin screen assertions:')); // Check if the create an order link is present. @@ -257,19 +257,19 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Check if there is at least an order created and the correct one is // present. - $this->assertNoText(t('No orders have been created yet.'), t('Order admin screen has at least one order')); - $this->assertText($this->order->order_number, t('The order number for the created order is present')); - $this->assertText($status['title'], t('The order status for the created order is present')); - $this->assertText($this->store_customer->name, t('The name of the order owner for the created order is present')); + $this->assertNoText(t('No orders have been created yet.'), 'Order admin screen has at least one order'); + $this->assertText($this->order->order_number, 'The order number for the created order is present'); + $this->assertText($status['title'], 'The order status for the created order is present'); + $this->assertText($this->store_customer->name, 'The name of the order owner for the created order is present'); // Check if the links for editing the order are present. $links = menu_contextual_links('commerce-order', 'admin/commerce/orders', array($this->order->order_id)); // Reset the cache as we don't want to keep the lock. entity_get_controller('commerce_order')->resetCache(); - $this->assertRaw((theme('links', array('links' => $links, 'attributes' => array('class' => array('links', 'inline', 'operations'))))), t('Links for orders are present')); + $this->assertRaw((theme('links', array('links' => $links, 'attributes' => array('class' => array('links', 'inline', 'operations'))))), 'Links for orders are present'); $this->drupalGet('admin/commerce/orders/'. $this->order->order_id . '/view'); - $this->assertResponse(200, t('Store admin user can access the order view page')); + $this->assertResponse(200, 'Store admin user can access the order view page'); } /** @@ -281,12 +281,12 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Access the order profile menu page. $this->drupalGet('user/' . $this->store_customer->uid . '/orders'); - $this->assertResponse(200, t('Users can access to their own orders listing')); + $this->assertResponse(200, 'Users can access to their own orders listing'); // Access the order just created for the user. $this->drupalGet('user/' . $this->store_customer->uid . '/orders/' . $this->order->order_id); - $this->assertResponse(200, t('Users can access their own order details')); - $this->assertTitle(t('Order @number', array('@number' => $this->order->order_number)) . ' | Drupal', t('The order number accessed by the user matches the order from URL')); + $this->assertResponse(200, 'Users can access their own order details'); + $this->assertTitle(t('Order @number', array('@number' => $this->order->order_number)) . ' | Drupal', 'The order number accessed by the user matches the order from URL'); } @@ -302,11 +302,11 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Access the order profile menu page. $this->drupalGet('user/' . $this->store_customer->uid . '/orders'); - $this->assertResponse(404, t('Users are not able to access other user\'s orders listing')); + $this->assertResponse(404, 'Users are not able to access other user\'s orders listing'); // Access the order details. $this->drupalGet('user/' . $this->store_customer->uid . '/orders/' . $this->order->order_id); - $this->assertResponse(403, t('Users are not able to access other user\'s order details')); + $this->assertResponse(403, 'Users are not able to access other user\'s order details'); } /** @@ -319,7 +319,7 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the page to delete the order. $this->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/delete'); - $this->assertResponse(403, t('Normal user is not able to delete orders')); + $this->assertResponse(403, 'Normal user is not able to delete orders'); // Log in as store admin. $this->drupalLogin($this->store_admin); @@ -328,8 +328,8 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/delete'); // The confirmation page is accesible and the form is ok. - $this->assertResponse(200, t('Store admin user can access the order deletion page')); - $this->assertText(t('Deleting this order cannot be undone.'), t('The confirmation message for order delete is displayed')); + $this->assertResponse(200, 'Store admin user can access the order deletion page'); + $this->assertText(t('Deleting this order cannot be undone.'), 'The confirmation message for order delete is displayed'); // Delete the order. $this->drupalPost(NULL, array(), t('Delete')); @@ -337,12 +337,12 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Reload the order from database. $orders = commerce_order_load_multiple(array($this->order->order_id), array(), TRUE); $order = reset($orders); - $this->assertFalse($order, t('Order has been deleted from database')); + $this->assertFalse($order, 'Order has been deleted from database'); // Check if the confirmation message is displayed. - $this->assertText(t('Order @number has been deleted.', array('@number' => $this->order->order_number)), t('Order message for deletion is displayed with the correct order number')); + $this->assertText(t('Order @number has been deleted.', array('@number' => $this->order->order_number)), 'Order message for deletion is displayed with the correct order number'); // Check if the order is present in the page. - $this->assertText(t('No orders have been created yet.'), t('After deleting the only order created, there is no order left in the order admin screen')); + $this->assertText(t('No orders have been created yet.'), 'After deleting the only order created, there is no order left in the order admin screen'); } /** @@ -355,7 +355,7 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the page to configure the helper text. $this->drupalGet('admin/commerce/config/order'); - $this->assertResponse(403, t('Normal user is not able to configure the helper text for orders')); + $this->assertResponse(403, 'Normal user is not able to configure the helper text for orders'); // Log in as store admin. $this->drupalLogin($this->store_admin); @@ -363,10 +363,10 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the page to configure the helper text. $this->drupalGet('admin/commerce/config/order'); - $this->assertResponse(200, t('Store admin user can configure the helper text for orders')); + $this->assertResponse(200, 'Store admin user can configure the helper text for orders'); // Check the integrity of the form. - $this->assertFieldById('edit-commerce-order-help-text', NULL, t('Order help text textarea is available')); + $this->assertFieldById('edit-commerce-order-help-text', NULL, 'Order help text textarea is available'); // Save a random content for the help text. $edit = array( @@ -375,13 +375,13 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, $edit, t('Save configuration')); // Check if the text has been stored - $this->assertText(t('The configuration options have been saved.'), t('Confirmation message for saving the helper text is displayed')); - $this->assertFieldById('edit-commerce-order-help-text', $edit['commerce_order_help_text'], t('Order help text textarea displays the stored helper text')); - $this->assertTrue(variable_get('commerce_order_help_text', '') == $edit['commerce_order_help_text'], t('Order help text saved in database')); + $this->assertText(t('The configuration options have been saved.'), 'Confirmation message for saving the helper text is displayed'); + $this->assertFieldById('edit-commerce-order-help-text', $edit['commerce_order_help_text'], 'Order help text textarea displays the stored helper text'); + $this->assertTrue(variable_get('commerce_order_help_text', '') == $edit['commerce_order_help_text'], 'Order help text saved in database'); // Check if the text is displayed in the order creation page. $this->drupalGet('admin/commerce/orders/add'); - $this->assertText($edit['commerce_order_help_text'], t('Order help text message displayed in the order creation page')); + $this->assertText($edit['commerce_order_help_text'], 'Order help text message displayed in the order creation page'); } /** @@ -394,7 +394,7 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the manage fields screen for the order type. $this->drupalGet('admin/commerce/config/order/fields'); - $this->assertResponse(403, t('Normal user is not able to access the manage fields screen for the order type')); + $this->assertResponse(403, 'Normal user is not able to access the manage fields screen for the order type'); // Log in as store admin. $this->drupalLogin($this->store_admin); @@ -402,7 +402,7 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the manage fields screen for the order type. $this->drupalGet('admin/commerce/config/order/fields'); - $this->assertResponse(200, t('Store admin user can access the manage fields screen for the order type')); + $this->assertResponse(200, 'Store admin user can access the manage fields screen for the order type'); // Get the instances attached to the commerce order bundle and assert if // they are present in the form. @@ -422,7 +422,7 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the display fields screen for the order type. $this->drupalGet('admin/commerce/config/order/display'); - $this->assertResponse(403, t('Normal user is not able to access the display fields screen for the order type')); + $this->assertResponse(403, 'Normal user is not able to access the display fields screen for the order type'); // Log in as store admin. $this->drupalLogin($this->store_admin); @@ -430,7 +430,7 @@ class CommerceOrderUIAdminTest extends CommerceBaseTestCase { // Navigate to the display fields screen for the order type. $this->drupalGet('admin/commerce/config/order/display'); - $this->assertResponse(200, t('Store admin user can access the display fields screen for the order type')); + $this->assertResponse(200, 'Store admin user can access the display fields screen for the order type'); // Assert the field instances for the display. $field_instances = field_info_instances('commerce_order', 'commerce_order'); diff --git a/modules/payment/tests/commerce_payment_ui.test b/modules/payment/tests/commerce_payment_ui.test index b59e6573..975c7fd3 100644 --- a/modules/payment/tests/commerce_payment_ui.test +++ b/modules/payment/tests/commerce_payment_ui.test @@ -61,8 +61,8 @@ class CommercePaymentUITest extends CommerceBaseTestCase { $this->drupalGet($this->getCommerceUrl('checkout')); // Check if the page resolves and if the default panes are present. - $this->assertResponse(200, t('Store customer user is able to access the checkout page')); - $this->assertTitle(t('Checkout') . ' | Drupal', t('Checkout page successfully loaded')); + $this->assertResponse(200, 'Store customer user is able to access the checkout page'); + $this->assertTitle(t('Checkout') . ' | Drupal', 'Checkout page successfully loaded'); // Generate random information, as city, postal code, etc. $address_info = $this->generateAddressInformation(); @@ -73,7 +73,7 @@ class CommercePaymentUITest extends CommerceBaseTestCase { // Check if the country has been selected correctly, this uses XPath as the // ajax call replaces the element and the id may change. - $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', t('Country selected')); + $this->assertFieldByXPath("//select[starts-with(@id, 'edit-customer-profile-billing-commerce-customer-address')]//option[@selected='selected']", 'US', 'Country selected'); // Fill in the required information for billing pane, with a random State. $info = array( @@ -86,7 +86,7 @@ class CommercePaymentUITest extends CommerceBaseTestCase { $this->drupalPost(NULL, $info, t('Continue to next step')); // Check for default panes and information in this checkout phase. - $this->assertTitle(t('Review order') . ' | Drupal', t('Review order page successfully loaded')); + $this->assertTitle(t('Review order') . ' | Drupal', 'Review order page successfully loaded'); } /** @@ -95,7 +95,7 @@ class CommercePaymentUITest extends CommerceBaseTestCase { public function testCommercePaymentCheckout() { $this->createOrderAndGoToPayment(); - $this->assertText('Example payment', t('Example payment method pane is present')); + $this->assertText('Example payment', 'Example payment method pane is present'); // Finish checkout process. $this->drupalPost(NULL, array(), t('Continue to next step')); @@ -104,10 +104,10 @@ class CommercePaymentUITest extends CommerceBaseTestCase { $payment = commerce_payment_transaction_load_multiple(array(), array('order_id' => $this->order->order_id), TRUE); // Order status should be pending when completing checkout process. - $this->assertEqual(reset($payment)->status, 'success', t('Payment was successfully processed')); + $this->assertEqual(reset($payment)->status, 'success', 'Payment was successfully processed'); // Check if the completion message has been displayed. - $this->assertTitle(t('Checkout complete') . ' | Drupal', t('Checkout process completed successfully')); + $this->assertTitle(t('Checkout complete') . ' | Drupal', 'Checkout process completed successfully'); } /** @@ -123,18 +123,18 @@ class CommercePaymentUITest extends CommerceBaseTestCase { // Go to payment administration page. $this->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/payment'); - $this->assertText(t('Payment'), t('Payment text found on the page.')); + $this->assertText(t('Payment'), 'Payment text found on the page.'); // Check order balance. $balance = commerce_payment_order_balance($this->order); - $this->assertRaw('' . t('Order balance') . '' . commerce_currency_format($balance['amount'], $balance['currency_code']) . '', t('Order balance is equal to order amount')); + $this->assertRaw('' . t('Order balance') . '' . commerce_currency_format($balance['amount'], $balance['currency_code']) . '', 'Order balance is equal to order amount'); // Add a payment for half of balance. $this->drupalPostAJAX(NULL, array('payment_method' => 'commerce_payment_example|commerce_payment_commerce_payment_example'), array('op' => t('Add payment'))); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-amount')]", NULL, t('Amount field is present')); - $this->assertFieldByXPath("//select[starts-with(@id, 'edit-currency-code')]", NULL, t('Currency code field is present')); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-payment-details-credit-card-number')]", NULL, t('Credit card number field from payment example module is present')); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-submit')]", NULL, t('Save button is present')); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-amount')]", NULL, 'Amount field is present'); + $this->assertFieldByXPath("//select[starts-with(@id, 'edit-currency-code')]", NULL, 'Currency code field is present'); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-payment-details-credit-card-number')]", NULL, 'Credit card number field from payment example module is present'); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-submit')]", NULL, 'Save button is present'); $payment_amount = intval($balance['amount'] / 2); $post_data = array( 'amount' => (commerce_currency_amount_to_decimal($payment_amount, $balance['currency_code'])), @@ -149,16 +149,16 @@ class CommercePaymentUITest extends CommerceBaseTestCase { // Check order balance, it should be half of total now. $new_balance = commerce_payment_order_balance(reset($order)); - $this->assertEqual($new_balance['amount'], $balance['amount'] - $payment_amount, t('After half payment order balance is correct')); - $this->assertRaw('' . t('Total paid') . '' . commerce_currency_format($payment_amount, $post_data['currency_code']) . '', t('Total paid reflects the payment')); - $this->assertRaw('' . t('Order balance') . '' . commerce_currency_format($new_balance['amount'], $new_balance['currency_code']) . '', t('Order balance is displayed correctly')); + $this->assertEqual($new_balance['amount'], $balance['amount'] - $payment_amount, 'After half payment order balance is correct'); + $this->assertRaw('' . t('Total paid') . '' . commerce_currency_format($payment_amount, $post_data['currency_code']) . '', 'Total paid reflects the payment'); + $this->assertRaw('' . t('Order balance') . '' . commerce_currency_format($new_balance['amount'], $new_balance['currency_code']) . '', 'Order balance is displayed correctly'); // Add a payment for the remainder. $this->drupalPostAJAX(NULL, array('payment_method' => 'commerce_payment_example|commerce_payment_commerce_payment_example'), array('op' => t('Add payment'))); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-amount')]", NULL, t('Amount field is present')); - $this->assertFieldByXPath("//select[starts-with(@id, 'edit-currency-code')]", NULL, t('Currency code field is present')); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-payment-details-credit-card-number')]", NULL, t('Credit card number field from payment example module is present')); - $this->assertFieldByXPath("//input[starts-with(@id, 'edit-submit')]", NULL, t('Save button is present')); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-amount')]", NULL, 'Amount field is present'); + $this->assertFieldByXPath("//select[starts-with(@id, 'edit-currency-code')]", NULL, 'Currency code field is present'); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-payment-details-credit-card-number')]", NULL, 'Credit card number field from payment example module is present'); + $this->assertFieldByXPath("//input[starts-with(@id, 'edit-submit')]", NULL, 'Save button is present'); $post_data = array( 'amount' => commerce_currency_amount_to_decimal($new_balance['amount'], $new_balance['currency_code']), 'currency_code' => 'USD', @@ -170,9 +170,9 @@ class CommercePaymentUITest extends CommerceBaseTestCase { // Check order balance, it should be zero now. $new_balance = commerce_payment_order_balance(reset($order)); - $this->assertEqual($new_balance['amount'], 0, t('Order balance is now zero')); - $this->assertRaw('' . t('Total paid') . '' . commerce_currency_format($balance['amount'], $balance['currency_code']) . '', t('Total paid is now equal to order total')); - $this->assertRaw('' . t('Order balance') . '' . commerce_currency_format(0, $new_balance['currency_code']) . '', t('Balance is displayed as zero')); + $this->assertEqual($new_balance['amount'], 0, 'Order balance is now zero'); + $this->assertRaw('' . t('Total paid') . '' . commerce_currency_format($balance['amount'], $balance['currency_code']) . '', 'Total paid is now equal to order total'); + $this->assertRaw('' . t('Order balance') . '' . commerce_currency_format(0, $new_balance['currency_code']) . '', 'Balance is displayed as zero'); } /** @@ -185,8 +185,8 @@ class CommercePaymentUITest extends CommerceBaseTestCase { // Go to payment methods page. $this->drupalGet('admin/commerce/config/payment-methods'); - $this->assertTitle(t('Payment methods') . ' | Drupal', t('We are now in the payment methods page')); - $this->assertText(t('Example payment'), t('Example payment rule is present')); + $this->assertTitle(t('Payment methods') . ' | Drupal', 'We are now in the payment methods page'); + $this->assertText(t('Example payment'), 'Example payment rule is present'); // Go to edit example payment rule. $this->clickLink(t('Example payment')); @@ -196,29 +196,29 @@ class CommercePaymentUITest extends CommerceBaseTestCase { // Create new data comparison condition for amount > $50. $this->drupalPost(NULL, array('element_name' => 'data_is'), t('Continue')); - $this->assertText(t('Compare two data values of the same type with each other.'), t('Second step page for adding a condition was successfully loaded')); + $this->assertText(t('Compare two data values of the same type with each other.'), 'Second step page for adding a condition was successfully loaded'); $this->drupalPost(NULL, array('parameter[data][settings][data:select]' => 'commerce-order:commerce-order-total:amount'), t('Continue')); - $this->assertText(t('The data to be compared, specified by using a data selector, e.g. "node:author:name".'), t('Third step page for adding a condition was successfully loaded')); + $this->assertText(t('The data to be compared, specified by using a data selector, e.g. "node:author:name".'), 'Third step page for adding a condition was successfully loaded'); $this->drupalPost(NULL, array('parameter[op][settings][op]' => '>', 'parameter[value][settings][value]' => 50), t('Save')); - $this->assertText(t('Your changes have been saved.'), t('New condition was successfully added')); + $this->assertText(t('Your changes have been saved.'), 'New condition was successfully added'); // Adding a new action to enable the payment method if conditions are met. $this->clickLink(t('Add action')); $this->drupalPost(NULL, array('element_name' => 'commerce_payment_enable_commerce_payment_example'), t('Continue')); $this->drupalPost(NULL, array('parameter[commerce_order][settings][commerce_order:select]' => 'commerce-order'), t('Save')); - $this->assertText(t('Your changes have been saved.'), t('New action was successfully added')); + $this->assertText(t('Your changes have been saved.'), 'New action was successfully added'); // Create a less than $50 order (20 products $2 each). $product = $this->createDummyProduct($this->randomName(), $this->randomName(), 2, 'USD', $this->store_admin->uid); $this->createOrderAndGoToPayment($this->store_customer, array($product->product_id => 20)); // Check that the payment method example is *not* there. - $this->assertNoText('Example payment', t('Example payment method panel is not present')); + $this->assertNoText('Example payment', 'Example payment method panel is not present'); // Create a more than $50 order (40 products $2 each). $product = $this->createDummyProduct($this->randomName(), $this->randomName(), 2, 'USD', $this->store_admin->uid); $this->createOrderAndGoToPayment($this->store_customer, array($product->product_id => 40)); // Check that the payment method example is there. - $this->assertText('Example payment', t('Example payment method panel is present')); + $this->assertText('Example payment', 'Example payment method panel is present'); } /** @@ -234,12 +234,12 @@ class CommercePaymentUITest extends CommerceBaseTestCase { // Access payment administration page. $this->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/payment'); - $this->assertResponse(403, t('Normal user is not able to access the payment administration page')); + $this->assertResponse(403, 'Normal user is not able to access the payment administration page'); // Access to the payment methods administration page. $this->drupalGet('admin/commerce/config/payment-methods'); - $this->assertResponse(403, t('Normal user is not able to access the payment methods administration page')); + $this->assertResponse(403, 'Normal user is not able to access the payment methods administration page'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -247,12 +247,12 @@ class CommercePaymentUITest extends CommerceBaseTestCase { // Access payment administration page. $this->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/payment'); - $this->assertResponse(200, t('Store admin user can access the payment administration page')); + $this->assertResponse(200, 'Store admin user can access the payment administration page'); // Access to the payment methods administration page $this->drupalGet('admin/commerce/config/payment-methods'); - $this->assertResponse(200, t('Store admin user can access the payment methods administration page')); + $this->assertResponse(200, 'Store admin user can access the payment methods administration page'); } } @@ -307,7 +307,7 @@ class CommercePaymentOffsiteTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/payment-methods'); // Check if the payment method exists and it's listed. - $this->assertText(t('Dummy Payment Method Offsite'), t('Offsite example payment method is listed in the payment methods administration page')); + $this->assertText(t('Dummy Payment Method Offsite'), 'Offsite example payment method is listed in the payment methods administration page'); // Login with store customer and access to checkout. $this->drupalLogin($this->store_customer); @@ -315,11 +315,11 @@ class CommercePaymentOffsiteTest extends CommerceBaseTestCase { // Process the order and check if the offsite payment is working. $this->drupalPost(NULL, array(), t('Continue to next step')); - $this->assertText(t('Dummy Payment Method Offsite'), t('Offsite example payment method is listed in the checkout process form')); + $this->assertText(t('Dummy Payment Method Offsite'), 'Offsite example payment method is listed in the checkout process form'); $this->drupalPostAJAX(NULL, array('commerce_payment[payment_method]' => 'commerce_payment_dummy_offsite|commerce_payment_commerce_payment_dummy_offsite'), 'commerce_payment[payment_method]'); $this->drupalPost(NULL, array(), t('Continue to next step')); - $this->assertFieldById('edit-submit', t('Redirect to Offsite platform'), t('Redirection button to offsite payment platform is present')); + $this->assertFieldById('edit-submit', t('Redirect to Offsite platform'), 'Redirection button to offsite payment platform is present'); // We can't really test further than this. } diff --git a/modules/product/tests/commerce_product.test b/modules/product/tests/commerce_product.test index 56ca8bd4..635fed36 100644 --- a/modules/product/tests/commerce_product.test +++ b/modules/product/tests/commerce_product.test @@ -140,7 +140,7 @@ class CommerceProductCRUDTestCase extends CommerceBaseTestCase { // Ensure hooks invoked during the save operation can load identical objects // be checking a global variable set in commerce_product_crud_test_commerce_product_update() // if the uid is in fact being loaded as 0 in the update hook. - $this->assertTrue($commerce_product_crud_tests['hook_update_identical_uid'], t('Invoked hooks during save operation can successfully load identical object.')); + $this->assertTrue($commerce_product_crud_tests['hook_update_identical_uid'], 'Invoked hooks during save operation can successfully load identical object.'); // Ensure commerce_product_load_by_sku() can load a product by SKU. $loaded_product_by_sku = commerce_product_load_by_sku($sku); diff --git a/modules/product/tests/commerce_product_ui.test b/modules/product/tests/commerce_product_ui.test index 9f5a5d0a..c5ff2110 100644 --- a/modules/product/tests/commerce_product_ui.test +++ b/modules/product/tests/commerce_product_ui.test @@ -58,7 +58,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the admin product list. $this->drupalGet('admin/commerce/products'); - $this->assertResponse(403, t('Normal user is not able to access the product admin list page')); + $this->assertResponse(403, 'Normal user is not able to access the product admin list page'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -66,7 +66,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the admin product list. $this->drupalGet('admin/commerce/products'); - $this->assertResponse(200, t('Store admin user can access the product admin list page')); + $this->assertResponse(200, 'Store admin user can access the product admin list page'); // Ensure that the link for create products is in place. $this->assertText(t('Add a product'), t('%addproduct link is present in the admin list page', array('%addproduct' => t('Add a product')))); @@ -82,7 +82,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the admin product creation page. $this->drupalGet('admin/commerce/products/add/product'); - $this->assertResponse(403, t('Normal user is not able to add a product using the admin interface')); + $this->assertResponse(403, 'Normal user is not able to add a product using the admin interface'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -90,27 +90,27 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the admin product creation page. $this->drupalGet('admin/commerce/products/add/product'); - $this->assertResponse(200, t('Store admin user is allowed to add a product using the admin interface')); + $this->assertResponse(200, 'Store admin user is allowed to add a product using the admin interface'); // Check the integrity of the add form. $this->pass(t('Test the integrity of the product add form:')); - $this->assertFieldByName('sku', NULL, t('SKU field is present')); - $this->assertFieldByXPath('//input[@name="sku" and contains(@class, "required")]', NULL, t('SKU field is required')); - $this->assertFieldByName('title', NULL, t('Title field is present')); + $this->assertFieldByName('sku', NULL, 'SKU field is present'); + $this->assertFieldByXPath('//input[@name="sku" and contains(@class, "required")]', NULL, 'SKU field is required'); + $this->assertFieldByName('title', NULL, 'Title field is present'); $this->assertFieldByXPath('//input[@name="title" and contains(@class, "required")]', NULL, t('Title field is required')); - $this->assertFieldByName('commerce_price[und][0][amount]', NULL, t('Price field is present')); - $this->assertFieldByName('status', NULL, t('Status field is present')); + $this->assertFieldByName('commerce_price[und][0][amount]', NULL, 'Price field is present'); + $this->assertFieldByName('status', NULL, 'Status field is present'); $status_required = $this->xpath('//div[contains(@class, "form-item-status")]/label/span[contains(@class, "form-required")]'); - $this->assertFalse(empty($status_required), t('Status field is required')); - $this->assertFieldById('edit-submit', t('Save product'), t('Save product button is present')); - $this->assertFieldById('edit-save-continue', t('Save and add another'), t('Save an add another button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/products'), t('Cancel link is present')); + $this->assertFalse(empty($status_required), 'Status field is required'); + $this->assertFieldById('edit-submit', t('Save product'), 'Save product button is present'); + $this->assertFieldById('edit-save-continue', t('Save and add another'), 'Save an add another button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/products'), 'Cancel link is present'); // Try to save the product and check validation messages. $this->drupalPost(NULL, array(), t('Save product')); - $this->assertText(t('Product SKU field is required'), t('Validation message for SKU is displayed when tryin to submit the form with the field empty.')); - $this->assertText(t('Title field is required'), t('Validation message for title is displayed when tryin to submit the form with the field empty.')); + $this->assertText(t('Product SKU field is required'), 'Validation message for SKU is displayed when tryin to submit the form with the field empty.'); + $this->assertText(t('Title field is required'), 'Validation message for title is displayed when tryin to submit the form with the field empty.'); // Create the product. $price = rand(2,500); @@ -128,18 +128,18 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Check the product in database $this->pass(t('Test the product creation in database:')); - $this->assertTrue($product_wrapper->sku->value() == $edit['sku'], t('SKU stored in database correctly set')); - $this->assertTrue($product_wrapper->title->value() == $edit['title'], t('Title stored in database correctly set')); + $this->assertTrue($product_wrapper->sku->value() == $edit['sku'], 'SKU stored in database correctly set'); + $this->assertTrue($product_wrapper->title->value() == $edit['title'], 'Title stored in database correctly set'); - $this->assertTrue($product_wrapper->commerce_price->amount->value() == $price, t('Amount stored in database correctly set')); - $this->assertTrue($product->status == $edit['status'], t('Status stored in database correctly set')); + $this->assertTrue($product_wrapper->commerce_price->amount->value() == $price, 'Amount stored in database correctly set'); + $this->assertTrue($product->status == $edit['status'], 'Status stored in database correctly set'); // Check the product listing $this->pass(t('Test the product listing after saving a product')); - $this->assertTrue($this->url == url('admin/commerce/products', array('absolute' => TRUE)), t('Landing page after save is the list of products')); + $this->assertTrue($this->url == url('admin/commerce/products', array('absolute' => TRUE)), 'Landing page after save is the list of products'); $this->assertText(t('Product saved.'), t('%message message is present', array('%message' => t('Product saved')))); - $this->assertText($edit['sku'], t('SKU of the product is present')); - $this->assertText($edit['title'], t('Title of the product is present')); + $this->assertText($edit['sku'], 'SKU of the product is present'); + $this->assertText($edit['title'], 'Title of the product is present'); // Assert the product creation. $this->assertProductCreated($product, $this->store_admin); @@ -171,13 +171,13 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { $product = commerce_product_load_by_sku($edit['sku']); $product_wrapper = entity_metadata_wrapper('commerce_product', $product); $this->pass(t('Test the product creation in database:')); - $this->assertTrue($product_wrapper->sku->value() == $edit['sku'], t('SKU stored in database correctly set')); - $this->assertTrue($product_wrapper->title->value() == $edit['title'], t('Title stored in database correctly set')); - $this->assertTrue($product_wrapper->commerce_price->amount->value() == $price, t('Amount stored in database correctly set')); - $this->assertTrue($product->status == $edit['status'], t('Status stored in database correctly set')); + $this->assertTrue($product_wrapper->sku->value() == $edit['sku'], 'SKU stored in database correctly set'); + $this->assertTrue($product_wrapper->title->value() == $edit['title'], 'Title stored in database correctly set'); + $this->assertTrue($product_wrapper->commerce_price->amount->value() == $price, 'Amount stored in database correctly set'); + $this->assertTrue($product->status == $edit['status'], 'Status stored in database correctly set'); // Check if we are in the product creation page. - $this->assertTrue($this->url == url('admin/commerce/products/add/product', array('absolute' => TRUE)), t('Landing page after save and add another is the product creation page')); + $this->assertTrue($this->url == url('admin/commerce/products/add/product', array('absolute' => TRUE)), 'Landing page after save and add another is the product creation page'); } /** @@ -194,7 +194,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the edit product page. $this->drupalGet('admin/commerce/products/' . $product->product_id . '/edit'); - $this->assertResponse(403, t('Normal user is not able to access the product edit page')); + $this->assertResponse(403, 'Normal user is not able to access the product edit page'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -202,16 +202,16 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the edit product page. $this->drupalGet('admin/commerce/products/' . $product->product_id . '/edit'); - $this->assertResponse(200, t('Store admin user can access the product edit page')); + $this->assertResponse(200, 'Store admin user can access the product edit page'); // Check the fields and buttons for the edit product form. $this->pass(t('Test the integrity of the edit product form:')); - $this->assertFieldByName('sku', $product_wrapper->sku->value(), t('SKU field is present')); - $this->assertFieldByName('title', $product_wrapper->title->value(), t('Title field is present')); - $this->assertFieldByName('commerce_price[und][0][amount]', commerce_currency_amount_to_decimal($product_wrapper->commerce_price->amount->value(), $product_wrapper->commerce_price->currency_code->value()), t('Price field is present')); - $this->assertFieldByName('status', $product->status, t('Status field is present')); - $this->assertFieldById('edit-submit', t('Save product'), t('Save product button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/products'), t('Cancel link is present')); + $this->assertFieldByName('sku', $product_wrapper->sku->value(), 'SKU field is present'); + $this->assertFieldByName('title', $product_wrapper->title->value(), 'Title field is present'); + $this->assertFieldByName('commerce_price[und][0][amount]', commerce_currency_amount_to_decimal($product_wrapper->commerce_price->amount->value(), $product_wrapper->commerce_price->currency_code->value()), 'Price field is present'); + $this->assertFieldByName('status', $product->status, 'Status field is present'); + $this->assertFieldById('edit-submit', t('Save product'), 'Save product button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/products'), 'Cancel link is present'); // Change the product values. $price = rand(2, 500); @@ -227,21 +227,21 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { $product = commerce_product_load_by_sku($edit['sku']); $product_wrapper = entity_metadata_wrapper('commerce_product', $product); $this->pass(t('Test the product edit in database:')); - $this->assertTrue($product_wrapper->sku->value() == $edit['sku'], t('SKU stored in database correctly set')); - $this->assertTrue($product_wrapper->title->value() == $edit['title'], t('Title stored in database correctly set')); - $this->assertTrue($product_wrapper->commerce_price->amount->value() == $price, t('Amount stored in database correctly set')); - $this->assertTrue($product->status == $edit['status'], t('Status stored in database correctly set')); + $this->assertTrue($product_wrapper->sku->value() == $edit['sku'], 'SKU stored in database correctly set'); + $this->assertTrue($product_wrapper->title->value() == $edit['title'], 'Title stored in database correctly set'); + $this->assertTrue($product_wrapper->commerce_price->amount->value() == $price, 'Amount stored in database correctly set'); + $this->assertTrue($product->status == $edit['status'], 'Status stored in database correctly set'); // Check the product listing $this->pass(t('Test the product form after editing a product')); - $this->assertTrue($this->url == url('admin/commerce/products/' . $product->product_id . '/edit', array('absolute' => TRUE)), t('Landing page after save is the list of products')); + $this->assertTrue($this->url == url('admin/commerce/products/' . $product->product_id . '/edit', array('absolute' => TRUE)), 'Landing page after save is the list of products'); $this->assertText(t('Product saved.'), t('%message message is present', array('%message' => t('Product saved')))); - $this->assertFieldByName('sku', $edit['sku'], t('SKU field has the correct value')); - $this->assertFieldByName('title', $edit['title'], t('Title field has the correct value')); - $this->assertFieldByName('commerce_price[und][0][amount]', $edit['commerce_price[und][0][amount]'], t('Price field has the correct value')); - $this->assertFieldByName('status', $edit['status'], t('Status field is present')); - $this->assertFieldById('edit-submit', t('Save product'), t('Save product button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/products'), t('Cancel link is present')); + $this->assertFieldByName('sku', $edit['sku'], 'SKU field has the correct value'); + $this->assertFieldByName('title', $edit['title'], 'Title field has the correct value'); + $this->assertFieldByName('commerce_price[und][0][amount]', $edit['commerce_price[und][0][amount]'], 'Price field has the correct value'); + $this->assertFieldByName('status', $edit['status'], 'Status field is present'); + $this->assertFieldById('edit-submit', t('Save product'), 'Save product button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/products'), 'Cancel link is present'); } /** @@ -257,7 +257,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Click on cancel link. $this->clickLink(t('Cancel')); - $this->assertTrue($this->url == url('admin/commerce/products', array('absolute' => TRUE)), t('Landing page after cancel is the product listing page')); + $this->assertTrue($this->url == url('admin/commerce/products', array('absolute' => TRUE)), 'Landing page after cancel is the product listing page'); } /** @@ -273,7 +273,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the delete product page. $this->drupalGet('admin/commerce/products/' . $product->product_id . '/delete'); - $this->assertResponse(403, t('Normal user is not able to access the product deletion page')); + $this->assertResponse(403, 'Normal user is not able to access the product deletion page'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -281,30 +281,30 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the delete product page. $this->drupalGet('admin/commerce/products/' . $product->product_id . '/delete'); - $this->assertResponse(200, t('Store admin user can access the product delete page')); + $this->assertResponse(200, 'Store admin user can access the product delete page'); // Check the integrity of the product delete confirmation form. $this->pass('Test the product delete confirmation form:'); - $this->assertTitle(t('Are you sure you want to delete !title?', array('!title' => $product->title)) . ' | Drupal', t('The confirmation message is displayed')); - $this->assertText($product->sku, t('SKU of the product is present')); - $this->assertText($product->title, t('Title of the product is present')); - $this->assertText(t('Deleting this product cannot be undone.', array('@sku' => $product->sku)), t('A warning notifying the user about the action can\'t be undone is displayed.')); - $this->assertFieldById('edit-submit', t('Delete'), t('Delete button is present')); - $this->assertText(t('Cancel'), t('Cancel is present')); + $this->assertTitle(t('Are you sure you want to delete !title?', array('!title' => $product->title)) . ' | Drupal', 'The confirmation message is displayed'); + $this->assertText($product->sku, 'SKU of the product is present'); + $this->assertText($product->title, 'Title of the product is present'); + $this->assertText(t('Deleting this product cannot be undone.', array('@sku' => $product->sku)), 'A warning notifying the user about the action can\'t be undone is displayed.'); + $this->assertFieldById('edit-submit', t('Delete'), 'Delete button is present'); + $this->assertText(t('Cancel'), 'Cancel is present'); // Delete the product $this->drupalPost(NULL, array(), t('Delete')); // Check for the product in database. $deleted_product = commerce_product_load_multiple(array($product->product_id), array(), TRUE); - $this->assertFalse(reset($deleted_product), t('After deleting it, the product is no more in database')); + $this->assertFalse(reset($deleted_product), 'After deleting it, the product is no more in database'); - $this->assertTrue($this->url == url('admin/commerce/products', array('absolute' => TRUE)), t('Landing page after deleting a product is the product listing page')); + $this->assertTrue($this->url == url('admin/commerce/products', array('absolute' => TRUE)), 'Landing page after deleting a product is the product listing page'); // Check if the product is present in the product listing. - $this->assertRaw(t('%title has been deleted.', array('%title' => $product->title)), t('\'Product has been deleted\' message is displayed')); - $this->assertNoText($product->sku, t('Product SKU is not present')); - $this->assertText(t('No products have been created yet.'), t('Empty product listing message is displayed')); + $this->assertRaw(t('%title has been deleted.', array('%title' => $product->title)), '\'Product has been deleted\' message is displayed'); + $this->assertNoText($product->sku, 'Product SKU is not present'); + $this->assertText(t('No products have been created yet.'), 'Empty product listing message is displayed'); } @@ -325,8 +325,8 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/products/' . $product->product_id . '/delete'); $this->pass('Assertions for trying to delete a product associated to a line item:'); - $this->assertText(t('This product is referenced by a line item on Order @order_num and therefore cannot be deleted. Disable it instead.', array('@order_num' => $order->order_id)), t('Product delete restriction message is displayed correctly')); - $this->assertFieldByXPath('//input[@id="edit-submit" and @disabled="disabled"]', NULL, t('Delete button is present and is disabled')); + $this->assertText(t('This product is referenced by a line item on Order @order_num and therefore cannot be deleted. Disable it instead.', array('@order_num' => $order->order_id)), 'Product delete restriction message is displayed correctly'); + $this->assertFieldByXPath('//input[@id="edit-submit" and @disabled="disabled"]', NULL, 'Delete button is present and is disabled'); } /** @@ -339,7 +339,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product types listing. $this->drupalGet('admin/commerce/products/types'); - $this->assertResponse(403, t('Normal user is not able to access the product types listing page')); + $this->assertResponse(403, 'Normal user is not able to access the product types listing page'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -347,10 +347,10 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product types listing. $this->drupalGet('admin/commerce/products/types'); - $this->assertResponse(200, t('Store admin user can access the product types listing page')); + $this->assertResponse(200, 'Store admin user can access the product types listing page'); // Ensure that the link for create product types is in place. - $this->assertText(t('Add product type'), t('\'Add product type\' link is present in the admin list page')); + $this->assertText(t('Add product type'), '\'Add product type\' link is present in the admin list page'); // Get all the product types and check if they are listed. $product_types = commerce_product_types(); @@ -369,7 +369,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product types add form. $this->drupalGet('admin/commerce/products/types/add'); - $this->assertResponse(403, t('Normal user is not able to access the product types add page')); + $this->assertResponse(403, 'Normal user is not able to access the product types add page'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -377,7 +377,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product types add form. $this->drupalGet('admin/commerce/products/types/add'); - $this->assertResponse(200, t('Store admin user can access the product types add page')); + $this->assertResponse(200, 'Store admin user can access the product types add page'); // Create an additional product type. $edit = array( @@ -392,10 +392,10 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Check if the product type has been created in database and if it appears // in the product types listing. - $this->assertTrue(!empty($product_types[$edit['product_type[type]']]), t('Product type has been correctly created')); - $this->assertEqual($this->url, url('admin/commerce/products/types', array('absolute' => TRUE)), t('Redirect page after creating a product type is the product types listing')); - $this->assertText(t('Product type saved'), t('Message after saving a new product type is displayed')); - $this->assertText($edit['product_type[name]'], t('Product type just created appears in product types listing')); + $this->assertTrue(!empty($product_types[$edit['product_type[type]']]), 'Product type has been correctly created'); + $this->assertEqual($this->url, url('admin/commerce/products/types', array('absolute' => TRUE)), 'Redirect page after creating a product type is the product types listing'); + $this->assertText(t('Product type saved'), 'Message after saving a new product type is displayed'); + $this->assertText($edit['product_type[name]'], 'Product type just created appears in product types listing'); // Test the Add and save fields. // Access to the product types add form. @@ -406,11 +406,11 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { ); $this->drupalPost(NULL, $edit, t('Save and add fields')); - $this->assertEqual($this->url, url('admin/commerce/products/types/' . strtr($edit['product_type[type]'], '_', '-') . '/fields', array('absolute' => TRUE)), t('Redirect page after creating a product type using \'Save and add fields\' button is the product type field manage screen')); - $this->assertText(t('Product type saved'), t('Message after saving a new product type is displayed')); - $this->assertText(t('Product SKU'), t('SKU field is present in the product type manage fields screen')); - $this->assertText(t('Title'), t('Title field is present in the product type manage fields screen')); - $this->assertText(t('Status'), t('Status field is present in the product type manage fields screen')); + $this->assertEqual($this->url, url('admin/commerce/products/types/' . strtr($edit['product_type[type]'], '_', '-') . '/fields', array('absolute' => TRUE)), 'Redirect page after creating a product type using \'Save and add fields\' button is the product type field manage screen'); + $this->assertText(t('Product type saved'), 'Message after saving a new product type is displayed'); + $this->assertText(t('Product SKU'), 'SKU field is present in the product type manage fields screen'); + $this->assertText(t('Title'), 'Title field is present in the product type manage fields screen'); + $this->assertText(t('Status'), 'Status field is present in the product type manage fields screen'); // Check the field instances for that content type. field_cache_clear(); @@ -430,7 +430,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product types edit form. $this->drupalGet('admin/commerce/products/types/product/edit'); - $this->assertResponse(403, t('Normal user is not able to access the product types edit page')); + $this->assertResponse(403, 'Normal user is not able to access the product types edit page'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -438,13 +438,13 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product types edit form. $this->drupalGet('admin/commerce/products/types/product/edit'); - $this->assertResponse(200, t('Store admin user can access the product types edit page')); + $this->assertResponse(200, 'Store admin user can access the product types edit page'); // Load all product types. $product_types = commerce_product_types(); - $this->assertFieldById('edit-product-type-name', $product_types['product']['name'], t('Product type name appears in the correct field of product type edit form')); - $this->assertFieldById('edit-product-type-description', $product_types['product']['description'], t('Product type description appears in the correct field of product type edit form')); + $this->assertFieldById('edit-product-type-name', $product_types['product']['name'], 'Product type name appears in the correct field of product type edit form'); + $this->assertFieldById('edit-product-type-description', $product_types['product']['description'], 'Product type description appears in the correct field of product type edit form'); } /** @@ -457,7 +457,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the delete page for a product type. $this->drupalGet('admin/commerce/products/types/product/delete'); - $this->assertResponse(403, t('Normal user is not able to access delete page for the product type')); + $this->assertResponse(403, 'Normal user is not able to access delete page for the product type'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -465,31 +465,31 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the delete page for a product type. $this->drupalGet('admin/commerce/products/types/product/delete'); - $this->assertResponse(200, t('Store admin can access delete page for the product type')); + $this->assertResponse(200, 'Store admin can access delete page for the product type'); // Load all product types. $product_types = commerce_product_types(); // Check the integrity of the product type delete confirmation form. $this->pass('Test the product type delete confirmation form:'); - $this->assertTitle(t('Are you sure you want to delete the !name product type?', array('!name' => $product_types['product']['name'])) . ' | Drupal', t('The confirmation message is displayed')); - $this->assertText(t('This action cannot be undone'), t('A warning notifying the user about the action can\'t be undone is displayed.')); - $this->assertFieldById('edit-submit', t('Delete'), t('Delete button is present')); - $this->assertText(t('Cancel'), t('Cancel is present')); + $this->assertTitle(t('Are you sure you want to delete the !name product type?', array('!name' => $product_types['product']['name'])) . ' | Drupal', 'The confirmation message is displayed'); + $this->assertText(t('This action cannot be undone'), 'A warning notifying the user about the action can\'t be undone is displayed.'); + $this->assertFieldById('edit-submit', t('Delete'), 'Delete button is present'); + $this->assertText(t('Cancel'), 'Cancel is present'); // Delete the product type $this->drupalPost(NULL, array(), t('Delete')); - $this->assertTrue($this->url == url('admin/commerce/products/types', array('absolute' => TRUE)), t('Landing page after deleting a product is the product types listing page')); + $this->assertTrue($this->url == url('admin/commerce/products/types', array('absolute' => TRUE)), 'Landing page after deleting a product is the product types listing page'); // Check if the product is present in the product listing. - $this->assertRaw(t('The product type %name has been deleted.', array('%name' => $product_types['product']['name'])), t('\'Product type has been deleted\' message is displayed')); + $this->assertRaw(t('The product type %name has been deleted.', array('%name' => $product_types['product']['name'])), '\'Product type has been deleted\' message is displayed'); // Reload all product types. commerce_product_types_reset(); $product_types = commerce_product_types(); // Look for the product type. - $this->assertTrue(empty($product_types['product']), t('Product type doesn\'t exist anymore after deletion')); + $this->assertTrue(empty($product_types['product']), 'Product type doesn\'t exist anymore after deletion'); } /** @@ -511,7 +511,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // As the product type has at least one product, it souldn't permit to be // deleted. $this->pass(t('Product type has at least one product, test the validation messages:')); - $this->assertTitle(t('Cannot delete the !name product type', array('!name' => $product_types['product']['name'])) . ' | Drupal', t('Validation title of the page displayed correctly.')); + $this->assertTitle(t('Cannot delete the !name product type', array('!name' => $product_types['product']['name'])) . ' | Drupal', 'Validation title of the page displayed correctly.'); // Get the count of products of the type $query = new EntityFieldQuery(); @@ -527,7 +527,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { 'There are @count products of this type. It cannot be deleted.' ); - $this->assertText($message, t('Display the reason why the product type cannot be deleted and show the number of products related to it')); + $this->assertText($message, 'Display the reason why the product type cannot be deleted and show the number of products related to it'); } /** @@ -540,7 +540,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product type manage fields screen. $this->drupalGet('admin/commerce/products/types/product/fields'); - $this->assertResponse(403, t('Normal user is not able to access the product type manage fields screen')); + $this->assertResponse(403, 'Normal user is not able to access the product type manage fields screen'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -548,7 +548,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product type manage fields screen. $this->drupalGet('admin/commerce/products/types/product/fields'); - $this->assertResponse(200, t('Store admin user can access the product type manage fields screen')); + $this->assertResponse(200, 'Store admin user can access the product type manage fields screen'); } /** @@ -561,7 +561,7 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product type display fields screen. $this->drupalGet('admin/commerce/products/types/product/display'); - $this->assertResponse(403, t('Normal user is not able to access the product type display fields screen')); + $this->assertResponse(403, 'Normal user is not able to access the product type display fields screen'); // Login with store admin. $this->drupalLogin($this->store_admin); @@ -569,6 +569,6 @@ class CommerceProductUIAdminTest extends CommerceBaseTestCase { // Access to the product type display fields screen. $this->drupalGet('admin/commerce/products/types/product/display'); - $this->assertResponse(200, t('Store admin user can access the product type display fields screen')); + $this->assertResponse(200, 'Store admin user can access the product type display fields screen'); } } diff --git a/modules/product_reference/tests/commerce_product_reference.test b/modules/product_reference/tests/commerce_product_reference.test index 27c43174..3a13b8f7 100644 --- a/modules/product_reference/tests/commerce_product_reference.test +++ b/modules/product_reference/tests/commerce_product_reference.test @@ -98,17 +98,17 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { */ public function testCommerceProductReferenceCreateField() { // Check at database level. - $this->assertTrue(in_array($this->display_type->type, $this->field['bundles']['node']), t('Field is present in the product display bundle')); - $this->assertTrue($this->field_instance['field_name'] == $this->field_name, t('Field instance is present in the product display bundle')); + $this->assertTrue(in_array($this->display_type->type, $this->field['bundles']['node']), 'Field is present in the product display bundle'); + $this->assertTrue($this->field_instance['field_name'] == $this->field_name, 'Field instance is present in the product display bundle'); // Check in the admin page for the content display. $this->drupalGet('admin/structure/types/manage/' . strtr($this->display_type->type, '_', '-') . '/fields'); - $this->assertText('Product', t('Reference product field label found')); - $this->assertText($this->field_name, t('Reference product field name found')); + $this->assertText('Product', 'Reference product field label found'); + $this->assertText($this->field_name, 'Reference product field name found'); // The product selector should appear in the product display creation page. $this->drupalGet('node/add/' . strtr($this->display_type->type, '_', '-')); - $this->assertFieldById('edit-field-product-und', NULL, t('Field selector is present in product display creation')); + $this->assertFieldById('edit-field-product-und', NULL, 'Field selector is present in product display creation'); } /** @@ -126,14 +126,14 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, $edit, t('Save settings')); // Check the message of configuration saved. - $this->assertRaw(t('Saved %label configuration.', array('%label' => $this->field_instance['label'])), t('Message of saved field displayed')); + $this->assertRaw(t('Saved %label configuration.', array('%label' => $this->field_instance['label'])), 'Message of saved field displayed'); // Navigate again to the edit field page to check if the values have been // saved. $this->drupalGet('admin/structure/types/manage/' . strtr($this->display_type->type, '_', '-') . '/fields/' . $this->field_name); - $this->assertFieldChecked('edit-instance-required', t('Required field is checked')); - $this->assertOptionSelected('edit-field-cardinality', -1, t('Field can have unlimited values')); - $this->assertFieldByXPath("//select[@id='edit-field-product-und' and @multiple='multiple']", NULL, t('Multiple product selector for default values')); + $this->assertFieldChecked('edit-instance-required', 'Required field is checked'); + $this->assertOptionSelected('edit-field-cardinality', -1, 'Field can have unlimited values'); + $this->assertFieldByXPath("//select[@id='edit-field-product-und' and @multiple='multiple']", NULL, 'Multiple product selector for default values'); // Clear field's cache. field_cache_clear(); @@ -143,7 +143,7 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { $this->drupalGet('node/add'); $this->drupalGet('node/add/' . strtr($this->display_type->type, '_', '-')); - $this->assertFieldByXPath("//select[@id='edit-field-product-und' and @multiple='multiple']", NULL, t('Multiple product selector for default values')); + $this->assertFieldByXPath("//select[@id='edit-field-product-und' and @multiple='multiple']", NULL, 'Multiple product selector for default values'); } /** @@ -175,17 +175,17 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { // Check the field at database level. $field = field_info_field('field_user_product'); $field_instance = field_info_instance('user', 'field_user_product','user'); - $this->assertTrue(in_array('user', $field['bundles']['user']), t('Field is present in the user')); - $this->assertTrue($field_instance['field_name'] == 'field_user_product', t('Field instance is present in the user bundle')); + $this->assertTrue(in_array('user', $field['bundles']['user']), 'Field is present in the user'); + $this->assertTrue($field_instance['field_name'] == 'field_user_product', 'Field instance is present in the user bundle'); // Check in the admin page for the user display. $this->drupalGet('admin/config/people/accounts/fields'); - $this->assertText('Product', t('Reference product field label found')); - $this->assertText('field_user_product', t('Reference product field name found')); + $this->assertText('Product', 'Reference product field label found'); + $this->assertText('field_user_product', 'Reference product field name found'); // The product selector should appear in the product display creation page. $this->drupalGet('admin/people/create'); - $this->assertFieldById('edit-field-user-product-und', NULL, t('Field selector is present in user creation')); + $this->assertFieldById('edit-field-user-product-und', NULL, 'Field selector is present in user creation'); } /** @@ -198,17 +198,17 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { // Check at database level $field_products = commerce_product_match_products($this->field, NULL, $new_product->sku, 'equals'); - $this->assertFalse(empty($field_products), t('Product is in the available products of the field')); + $this->assertFalse(empty($field_products), 'Product is in the available products of the field'); // Check if it is in the reference field for product displays. $this->drupalGet('admin/structure/types/manage/' . strtr($this->display_type->type, '_', '-') . '/fields/' . $this->field_name); $select_options = $this->xpath("//select[@id='edit-field-product-und']//option"); - $this->assertTrue(in_array($product_title, $select_options), t('Product is available in the select')); + $this->assertTrue(in_array($product_title, $select_options), 'Product is available in the select'); // Check if it is in the product display creation select form. $this->drupalGet('node/add/' . strtr($this->display_type->type, '_', '-')); $select_options = $this->xpath("//select[@id='edit-field-product-und']//option"); - $this->assertTrue(in_array($product_title, $select_options), t('Product is available in the select')); + $this->assertTrue(in_array($product_title, $select_options), 'Product is available in the select'); } /** @@ -223,28 +223,28 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { // Check if the additional type is available in the product display. $this->drupalGet('node/add/' . strtr($this->display_type->type, '_', '-')); $select_options = $this->xpath("//select[@id='edit-field-product-und']//option"); - $this->assertTrue(in_array($product_title, $select_options), t('Additional product is available in the select')); + $this->assertTrue(in_array($product_title, $select_options), 'Additional product is available in the select'); // Check if the additional type is available in the product field settings. $this->drupalGet('admin/structure/types/manage/' . strtr($this->display_type->type, '_', '-') . '/fields/' . $this->field_name); - $this->assertFieldById('edit-instance-settings-referenceable-types-additional-type', NULL, t('Additional product type is present')); + $this->assertFieldById('edit-instance-settings-referenceable-types-additional-type', NULL, 'Additional product type is present'); // Select only the additional type. $this->pass(t('Configure the display product reference field to only accept products from "Additional" type:')); $this->drupalPost(NULL, array('instance[settings][referenceable_types][additional_type]' => 1), t('Save settings')); // Check the saved message and the checkbox. - $this->assertRaw(t('Saved %label configuration.', array('%label' => $this->field_instance['label'])), t('Message of saved field displayed')); + $this->assertRaw(t('Saved %label configuration.', array('%label' => $this->field_instance['label'])), 'Message of saved field displayed'); $this->drupalGet('admin/structure/types/manage/' . strtr($this->display_type->type, '_', '-') . '/fields/' . $this->field_name); - $this->assertFieldChecked('edit-instance-settings-referenceable-types-additional-type', t('Required field is checked')); + $this->assertFieldChecked('edit-instance-settings-referenceable-types-additional-type', 'Required field is checked'); // Clear field's cache and reload field instance information just saved. field_cache_clear(); $field_instance = field_info_instance('node', $this->field_name, $this->display_type->type); // Check field instance settings. - $this->assertTrue($field_instance['settings']['referenceable_types']['additional_type'] == 'additional_type', t('Product type: Additional type is referenceable')); - $this->assertTrue($field_instance['settings']['referenceable_types']['product'] == 0, t('Product type: Product is not referenceable')); + $this->assertTrue($field_instance['settings']['referenceable_types']['additional_type'] == 'additional_type', 'Product type: Additional type is referenceable'); + $this->assertTrue($field_instance['settings']['referenceable_types']['product'] == 0, 'Product type: Product is not referenceable'); // Check if the additional type is available in the product display. $this->drupalGet('node/add/' . strtr($this->display_type->type, '_', '-')); @@ -280,15 +280,15 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, array('fields[field_product][type]' => 'commerce_product_reference_sku_link'), t('Save')); // Check if the value has been saved. - $this->assertText(t('Your settings have been saved.'), t('Settings saved message displayed')); - $this->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_sku_link', t('Correct value is selected.')); + $this->assertText(t('Your settings have been saved.'), 'Settings saved message displayed'); + $this->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_sku_link', 'Correct value is selected.'); // Clear field's cache and reload field instance information just saved. field_cache_clear(); $field_instance = field_info_instance('node', $this->field_name, $this->display_type->type); // Check if the value has been stored in db. - $this->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_sku_link', t('Option correctly stored in db')); + $this->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_sku_link', 'Option correctly stored in db'); // Create a product display using one product already generated. $product = reset($this->products); @@ -303,7 +303,7 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { '#title' => $product->sku, '#href' => 'admin/commerce/products/' . $product->product_id, ); - $this->assertRaw(drupal_render($render), t('SKU Link is displayed correctly')); + $this->assertRaw(drupal_render($render), 'SKU Link is displayed correctly'); } /** @@ -317,15 +317,15 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, array('fields[field_product][type]' => 'commerce_product_reference_sku_plain'), t('Save')); // Check if the value has been saved. - $this->assertText(t('Your settings have been saved.'), t('Settings saved message displayed')); - $this->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_sku_plain', t('Correct value is selected.')); + $this->assertText(t('Your settings have been saved.'), 'Settings saved message displayed'); + $this->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_sku_plain', 'Correct value is selected.'); // Clear field's cache and reload field instance information just saved. field_cache_clear(); $field_instance = field_info_instance('node', $this->field_name, $this->display_type->type); // Check if the value has been stored in db. - $this->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_sku_plain', t('Option correctly stored in db')); + $this->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_sku_plain', 'Option correctly stored in db'); // Create a product display using one product already generated. $product = reset($this->products); @@ -338,7 +338,7 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { $render = array( '#markup' => check_plain($product->sku), ); - $this->assertRaw(drupal_render($render), t('SKU without link is displayed correctly')); + $this->assertRaw(drupal_render($render), 'SKU without link is displayed correctly'); } /** @@ -352,15 +352,15 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, array('fields[field_product][type]' => 'commerce_product_reference_title_link'), t('Save')); // Check if the value has been saved. - $this->assertText(t('Your settings have been saved.'), t('Settings saved message displayed')); - $this->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_title_link', t('Correct value is selected.')); + $this->assertText(t('Your settings have been saved.'), 'Settings saved message displayed'); + $this->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_title_link', 'Correct value is selected.'); // Clear field's cache and reload field instance information just saved. field_cache_clear(); $field_instance = field_info_instance('node', $this->field_name, $this->display_type->type); // Check if the value has been stored in db. - $this->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_title_link', t('Option correctly stored in db')); + $this->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_title_link', 'Option correctly stored in db'); // Create a product display using one product already generated. $product = reset($this->products); @@ -375,7 +375,7 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { '#title' => $product->title, '#href' => 'admin/commerce/products/' . $product->product_id, ); - $this->assertRaw(drupal_render($render), t('Title Link is displayed correctly')); + $this->assertRaw(drupal_render($render), 'Title Link is displayed correctly'); } /** @@ -389,15 +389,15 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, array('fields[field_product][type]' => 'commerce_product_reference_title_plain'), t('Save')); // Check if the value has been saved. - $this->assertText(t('Your settings have been saved.'), t('Settings saved message displayed')); - $this->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_title_plain', t('Correct value is selected.')); + $this->assertText(t('Your settings have been saved.'), 'Settings saved message displayed'); + $this->assertOptionSelected('edit-fields-field-product-type', 'commerce_product_reference_title_plain', 'Correct value is selected.'); // Clear field's cache and reload field instance information just saved. field_cache_clear(); $field_instance = field_info_instance('node', $this->field_name, $this->display_type->type); // Check if the value has been stored in db. - $this->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_title_plain', t('Option correctly stored in db')); + $this->assertTrue($field_instance['display']['default']['type'] == 'commerce_product_reference_title_plain', 'Option correctly stored in db'); // Create a product display using one product already generated. $product = reset($this->products); @@ -410,6 +410,6 @@ class CommerceProductReferenceAdminTest extends CommerceBaseTestCase { $render = array( '#markup' => check_plain($product->title), ); - $this->assertRaw(drupal_render($render), t('Title with no Link is displayed correctly')); + $this->assertRaw(drupal_render($render), 'Title with no Link is displayed correctly'); } } diff --git a/modules/tax/tests/commerce_tax_ui.test b/modules/tax/tests/commerce_tax_ui.test index 7493d52c..64c6f4db 100644 --- a/modules/tax/tests/commerce_tax_ui.test +++ b/modules/tax/tests/commerce_tax_ui.test @@ -85,7 +85,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes'); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the tax rates listing page')); + $this->assertResponse(403, 'Normal user is not able to access the tax rates listing page'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -94,13 +94,13 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes'); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the tax rates listing page')); + $this->assertResponse(200, 'Store admin user can access the tax rates listing page'); // Check if the add link is there. $this->assertText(t('Add a tax rate'), t('%link link is present in the tax rates listing page', array('%link' => t('Add a tax rate')))); // There shouldn't be any tax rate yet. - $this->assertRaw(t('There are no tax rates yet. Add a tax rate.', array('@link' => url('admin/commerce/config/taxes/rates/add'))), t('Empty tax rate listing message is displayed')); + $this->assertRaw(t('There are no tax rates yet. Add a tax rate.', array('@link' => url('admin/commerce/config/taxes/rates/add'))), 'Empty tax rate listing message is displayed'); } /** @@ -114,7 +114,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/rates/add'); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the creation page for tax rates')); + $this->assertResponse(403, 'Normal user is not able to access the creation page for tax rates'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -123,23 +123,23 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/rates/add'); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the creation page for tax rates')); + $this->assertResponse(200, 'Store admin user can access the creation page for tax rates'); // Check the integrity of the tax rate form. $this->pass(t('Test the integrity of the tax rate add form:')); - $this->assertFieldByXPath('//input[@id="edit-tax-rate-title" and contains(@class, "required")]', NULL, t('Tax rate title field is present and is required')); - $this->assertFieldById('edit-tax-rate-display-title', NULL, t('Tax rate display title field is present')); - $this->assertFieldById('edit-tax-rate-description', NULL, t('Tax rate description is present')); - $this->assertFieldByXPath('//input[@id="edit-tax-rate-rate" and contains(@class, "required")]', 0, t('Tax rate rate field is present, has 0 as default value and is required')); - $this->assertFieldByXPath('//select[@id="edit-tax-rate-type" and contains(@class, "required")]', NULL, t('Tax rate type field is present and is required')); + $this->assertFieldByXPath('//input[@id="edit-tax-rate-title" and contains(@class, "required")]', NULL, 'Tax rate title field is present and is required'); + $this->assertFieldById('edit-tax-rate-display-title', NULL, 'Tax rate display title field is present'); + $this->assertFieldById('edit-tax-rate-description', NULL, 'Tax rate description is present'); + $this->assertFieldByXPath('//input[@id="edit-tax-rate-rate" and contains(@class, "required")]', 0, 'Tax rate rate field is present, has 0 as default value and is required'); + $this->assertFieldByXPath('//select[@id="edit-tax-rate-type" and contains(@class, "required")]', NULL, 'Tax rate type field is present and is required'); $tax_select_types = $this->xpath('//select[@id="edit-tax-rate-type"]//option'); foreach (commerce_tax_types() as $tax_type) { $this->assertTrue(in_array($tax_type['display_title'], (array)$tax_select_types), t('Tax rate type %type is available for the rate', array('%type' => $tax_type['display_title']))); } - $this->assertFieldById('edit-submit', t('Save tax rate'), t('\'Save tax rate\' button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/config/taxes'), t('Cancel link is present')); + $this->assertFieldById('edit-submit', t('Save tax rate'), '\'Save tax rate\' button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/config/taxes'), 'Cancel link is present'); // Fill the tax rate information and save tax rate. $edit = array( @@ -153,16 +153,16 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, $edit, t('Save tax rate')); // Check the url after creation and if the values have been saved. - $this->assertTrue($this->url == url('admin/commerce/config/taxes', array('absolute' => TRUE)), t('After saving a tax rate we are in the list of tax rates')); - $this->assertText($edit['tax_rate[title]'], t('Title of the tax rate is present in the tax rates listing')); - $this->assertText($edit['tax_rate[name]'], t('Machine name of the tax rate is present in the tax rates listing')); - $this->assertText($edit['tax_rate[description]'], t('Description of the tax rate is present in the tax rates listing')); - $this->assertText(trim($edit['tax_rate[rate]']), t('Rate value of the tax rate is present in the tax rates listing')); + $this->assertTrue($this->url == url('admin/commerce/config/taxes', array('absolute' => TRUE)), 'After saving a tax rate we are in the list of tax rates'); + $this->assertText($edit['tax_rate[title]'], 'Title of the tax rate is present in the tax rates listing'); + $this->assertText($edit['tax_rate[name]'], 'Machine name of the tax rate is present in the tax rates listing'); + $this->assertText($edit['tax_rate[description]'], 'Description of the tax rate is present in the tax rates listing'); + $this->assertText(trim($edit['tax_rate[rate]']), 'Rate value of the tax rate is present in the tax rates listing'); // Check in database if the tax rate has been created. commerce_tax_rates_reset(); $tax_rate = commerce_tax_rate_load($edit['tax_rate[name]']); - $this->assertFalse(empty($tax_rate), t('Tax is stored in database')); + $this->assertFalse(empty($tax_rate), 'Tax is stored in database'); } /** @@ -179,7 +179,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/rates/' . strtr($tax_rate['name'], '_', '-') . '/edit'); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the tax rate edit page')); + $this->assertResponse(403, 'Normal user is not able to access the tax rate edit page'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -188,18 +188,18 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/rates/' . strtr($tax_rate['name'], '_', '-') . '/edit'); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the tax rate edit page')); + $this->assertResponse(200, 'Store admin user can access the tax rate edit page'); // Check if the data loaded in the edit form matches with the tax rate. $this->pass(t('Test if the rate is correctly loaded in the edit form:')); - $this->assertFieldById('edit-tax-rate-title', $tax_rate['title'], t('Title field corresponds with tax rate')); - $this->assertText($tax_rate['name'], t('Machine name field corresponds with tax rate')); - $this->assertFieldById('edit-tax-rate-display-title', $tax_rate['display_title'], t('Display title field corresponds with tax rate')); - $this->assertFieldById('edit-tax-rate-rate', $tax_rate['rate'], t('Rate field corresponds with tax rate')); - $this->assertOptionSelected('edit-tax-rate-type', $tax_rate['type'], t('Type select value corresponds with tax rate')); - $this->assertFieldById('edit-submit', t('Save tax rate'), t('\'Save tax rate\' button is present')); - $this->assertFieldById('edit-delete', t('Delete tax rate'), t('Delete button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/config/taxes'), t('Cancel link is present')); + $this->assertFieldById('edit-tax-rate-title', $tax_rate['title'], 'Title field corresponds with tax rate'); + $this->assertText($tax_rate['name'], 'Machine name field corresponds with tax rate'); + $this->assertFieldById('edit-tax-rate-display-title', $tax_rate['display_title'], 'Display title field corresponds with tax rate'); + $this->assertFieldById('edit-tax-rate-rate', $tax_rate['rate'], 'Rate field corresponds with tax rate'); + $this->assertOptionSelected('edit-tax-rate-type', $tax_rate['type'], 'Type select value corresponds with tax rate'); + $this->assertFieldById('edit-submit', t('Save tax rate'), '\'Save tax rate\' button is present'); + $this->assertFieldById('edit-delete', t('Delete tax rate'), 'Delete button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/config/taxes'), 'Cancel link is present'); // Modify tax rate information and save the form. $edit = array( @@ -212,21 +212,21 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, $edit, t('Save tax rate')); // Check the url after edit and if the values have been loaded. - $this->assertTrue($this->url == url('admin/commerce/config/taxes', array('absolute' => TRUE)), t('After saving a tax rate we are in the list of tax rates')); - $this->assertText($edit['tax_rate[title]'], t('Title of the tax rate is present in the tax rates listing')); - $this->assertText($edit['tax_rate[description]'], t('Description of the tax rate is present in the tax rates listing')); - $this->assertText(trim($edit['tax_rate[rate]']), t('Rate value of the tax rate is present in the tax rates listing')); - $this->assertText(t('Tax rate saved.'), t('\'Tax rate saved\' message is displayed')); + $this->assertTrue($this->url == url('admin/commerce/config/taxes', array('absolute' => TRUE)), 'After saving a tax rate we are in the list of tax rates'); + $this->assertText($edit['tax_rate[title]'], 'Title of the tax rate is present in the tax rates listing'); + $this->assertText($edit['tax_rate[description]'], 'Description of the tax rate is present in the tax rates listing'); + $this->assertText(trim($edit['tax_rate[rate]']), 'Rate value of the tax rate is present in the tax rates listing'); + $this->assertText(t('Tax rate saved.'), '\'Tax rate saved\' message is displayed'); // Check in database if the tax rate has been correctly modified. commerce_tax_rates_reset(); $tax_rate = commerce_tax_rate_load($tax_rate['name']); - $this->assertFalse(empty($tax_rate), t('Tax is present in database')); - $this->assertTrue($tax_rate['title'] = $edit['tax_rate[title]'], t('Tax title is correctly saved in database')); - $this->assertTrue($tax_rate['display_title'] = $edit['tax_rate[display_title]'], t('Tax display title is correctly saved in database')); - $this->assertTrue($tax_rate['description'] = $edit['tax_rate[description]'], t('Tax description is correctly saved in database')); - $this->assertTrue($tax_rate['rate'] = $edit['tax_rate[rate]'], t('Tax rate is correctly saved in database')); - $this->assertTrue($tax_rate['type'] = $edit['tax_rate[type]'], t('Tax type is correctly saved in database')); + $this->assertFalse(empty($tax_rate), 'Tax is present in database'); + $this->assertTrue($tax_rate['title'] = $edit['tax_rate[title]'], 'Tax title is correctly saved in database'); + $this->assertTrue($tax_rate['display_title'] = $edit['tax_rate[display_title]'], 'Tax display title is correctly saved in database'); + $this->assertTrue($tax_rate['description'] = $edit['tax_rate[description]'], 'Tax description is correctly saved in database'); + $this->assertTrue($tax_rate['rate'] = $edit['tax_rate[rate]'], 'Tax rate is correctly saved in database'); + $this->assertTrue($tax_rate['type'] = $edit['tax_rate[type]'], 'Tax type is correctly saved in database'); } /** @@ -243,7 +243,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/rates/' . strtr($tax_rate['name'], '_', '-') . '/delete'); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the delete form of a tax rate')); + $this->assertResponse(403, 'Normal user is not able to access the delete form of a tax rate'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -252,27 +252,27 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/rates/' . strtr($tax_rate['name'], '_', '-') . '/delete'); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the delete form of a tax rate')); + $this->assertResponse(200, 'Store admin user can access the delete form of a tax rate'); // Check the integrity of the tax rate delete confirmation form. $this->pass('Test the tax rate delete confirmation form:'); - $this->assertTitle(t('Are you sure you want to delete the !title tax rate?', array('!title' => $tax_rate['title'])) . ' | Drupal', t('The confirmation message is displayed')); - $this->assertText(t('This action cannot be undone'), t('A warning notifying the user about the action can\'t be undone is displayed.')); - $this->assertFieldById('edit-submit', t('Delete'), t('Delete button is present')); - $this->assertText(t('Cancel'), t('Cancel is present')); + $this->assertTitle(t('Are you sure you want to delete the !title tax rate?', array('!title' => $tax_rate['title'])) . ' | Drupal', 'The confirmation message is displayed'); + $this->assertText(t('This action cannot be undone'), 'A warning notifying the user about the action can\'t be undone is displayed.'); + $this->assertFieldById('edit-submit', t('Delete'), 'Delete button is present'); + $this->assertText(t('Cancel'), 'Cancel is present'); // Confirm delete. $this->drupalPost(NULL, array(), t('Delete')); // Check the url after deleting and if the tax rate has been deleted in // database. - $this->assertTrue($this->url == url('admin/commerce/config/taxes', array('absolute' => TRUE)), t('Landing page after deleting a tax rate is the tax rates listing page')); - $this->assertRaw(t('The tax rate %title has been deleted.', array('%title' => $tax_rate['title'])), t('\'Tax rate has been deleted\' message is displayed')); - $this->assertRaw(t('There are no tax rates yet. Add a tax rate.', array('@link' => url('admin/commerce/config/taxes/rates/add'))), t('Empty tax rate listing message is displayed')); + $this->assertTrue($this->url == url('admin/commerce/config/taxes', array('absolute' => TRUE)), 'Landing page after deleting a tax rate is the tax rates listing page'); + $this->assertRaw(t('The tax rate %title has been deleted.', array('%title' => $tax_rate['title'])), '\'Tax rate has been deleted\' message is displayed'); + $this->assertRaw(t('There are no tax rates yet. Add a tax rate.', array('@link' => url('admin/commerce/config/taxes/rates/add'))), 'Empty tax rate listing message is displayed'); commerce_tax_rates_reset(); $tax_rate = commerce_tax_rate_load($tax_rate['name']); - $this->assertTrue(empty($tax_rate), t('Tax is correctly deleted from database')); + $this->assertTrue(empty($tax_rate), 'Tax is correctly deleted from database'); } /** @@ -289,7 +289,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/config/workflow/rules/components/manage/' . $tax_rate['rules_component']); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the component configure page for a tax rate')); + $this->assertResponse(403, 'Normal user is not able to access the component configure page for a tax rate'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -298,10 +298,10 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/config/workflow/rules/components/manage/' . $tax_rate['rules_component']); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the component configure page for a tax rate')); + $this->assertResponse(200, 'Store admin user can access the component configure page for a tax rate'); // Add a condition - $this->assertLink(t('Add condition'), 0, t('Add condition link is present')); + $this->assertLink(t('Add condition'), 0, 'Add condition link is present'); $this->clickLink(t('Add condition')); // Select a basic condition as at this step we're only testing if the @@ -312,8 +312,8 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { // Check that after saving the url is correct and the condition has been // added. - $this->assertTrue($this->url == url('admin/config/workflow/rules/components/manage/' . $tax_rate['rules_component'], array('absolute' => TRUE)), t('After adding a new condition component the landing page is the edit components one')); - $this->assertText(t('Entity is of type'), t('Condition was added correctly')); + $this->assertTrue($this->url == url('admin/config/workflow/rules/components/manage/' . $tax_rate['rules_component'], array('absolute' => TRUE)), 'After adding a new condition component the landing page is the edit components one'); + $this->assertText(t('Entity is of type'), 'Condition was added correctly'); } /** @@ -327,7 +327,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types'); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the tax types listing')); + $this->assertResponse(403, 'Normal user is not able to access the tax types listing'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -336,7 +336,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types'); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the tax types listing')); + $this->assertResponse(200, 'Store admin user can access the tax types listing'); // Load the tax rate types and check that all of them are in the page. $tax_types = commerce_tax_types(); @@ -359,7 +359,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types/add'); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the tax type creation')); + $this->assertResponse(403, 'Normal user is not able to access the tax type creation'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -368,16 +368,16 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types/add'); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the tax type creation')); + $this->assertResponse(200, 'Store admin user can access the tax type creation'); // Check the integrity of the creation form. $this->pass(t('Test the integrity of the tax type add form:')); - $this->assertFieldByXPath('//input[@id="edit-tax-type-title" and contains(@class, "required")]', NULL, t('Tax type title field is present and is required')); - $this->assertFieldById('edit-tax-type-display-title', NULL, t('Tax type display title is present')); - $this->assertFieldById('edit-tax-type-description', NULL, t('Tax type description is present')); - $this->assertFieldById('edit-tax-type-display-inclusive', NULL, t('Tax type checkbox for configure inclusive taxes is present')); - $this->assertFieldById('edit-submit', t('Save tax type'), t('\'Save tax type\' button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/config/taxes/types'), t('Cancel link is present')); + $this->assertFieldByXPath('//input[@id="edit-tax-type-title" and contains(@class, "required")]', NULL, 'Tax type title field is present and is required'); + $this->assertFieldById('edit-tax-type-display-title', NULL, 'Tax type display title is present'); + $this->assertFieldById('edit-tax-type-description', NULL, 'Tax type description is present'); + $this->assertFieldById('edit-tax-type-display-inclusive', NULL, 'Tax type checkbox for configure inclusive taxes is present'); + $this->assertFieldById('edit-submit', t('Save tax type'), '\'Save tax type\' button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/config/taxes/types'), 'Cancel link is present'); // Save the tax type. $edit = array( @@ -390,20 +390,20 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, $edit, t('Save tax type')); // Check the url after saving and if the tax type loads in the form. - $this->assertTrue($this->url == url('admin/commerce/config/taxes/types', array('absolute' => TRUE)), t('After saving a tax type we are in the list of tax types')); - $this->assertText($edit['tax_type[title]'], t('Title of the tax type is present in the tax rates listing')); - $this->assertText($edit['tax_type[name]'], t('Machine name of the tax type is present in the tax rates listing')); - $this->assertText($edit['tax_type[description]'], t('Description of the tax type is present in the tax rates listing')); + $this->assertTrue($this->url == url('admin/commerce/config/taxes/types', array('absolute' => TRUE)), 'After saving a tax type we are in the list of tax types'); + $this->assertText($edit['tax_type[title]'], 'Title of the tax type is present in the tax rates listing'); + $this->assertText($edit['tax_type[name]'], 'Machine name of the tax type is present in the tax rates listing'); + $this->assertText($edit['tax_type[description]'], 'Description of the tax type is present in the tax rates listing'); // Check in database if the tax rate has been created. commerce_tax_types_reset(); $tax_type = commerce_tax_type_load($edit['tax_type[name]']); - $this->assertFalse(empty($tax_type), t('Tax type is stored in database')); + $this->assertFalse(empty($tax_type), 'Tax type is stored in database'); // Create a tax rate and check that the new tax type is there. $this->drupalGet('admin/commerce/config/taxes/rates/add'); $tax_select_types = $this->xpath('//select[@id="edit-tax-rate-type"]//option'); - $this->assertTrue(in_array($this->tax_type['display_title'], $tax_select_types), t('Tax type is available in the tax rate creation form')); + $this->assertTrue(in_array($this->tax_type['display_title'], $tax_select_types), 'Tax type is available in the tax rate creation form'); } /** @@ -417,7 +417,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types/' . strtr($this->tax_type['name'], '_', '-') . '/edit'); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the tax type edit page')); + $this->assertResponse(403, 'Normal user is not able to access the tax type edit page'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -426,16 +426,16 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types/' . strtr($this->tax_type['name'], '_', '-') . '/edit'); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the tax type edit page')); + $this->assertResponse(200, 'Store admin user can access the tax type edit page'); // Check if the data loaded in the edit form matches with the tax type. $this->pass(t('Test if the type is correctly loaded in the edit form:')); - $this->assertFieldById('edit-tax-type-title', $this->tax_type['title'], t('Title field corresponds with tax type')); - $this->assertText($this->tax_type['name'], t('Machine name field corresponds with tax type')); - $this->assertFieldById('edit-tax-type-display-title', $this->tax_type['display_title'], t('Display title field corresponds with tax type')); - $this->assertFieldById('edit-submit', t('Save tax type'), t('\'Save tax rate\' button is present')); - $this->assertFieldById('edit-delete', t('Delete tax type'), t('Delete button is present')); - $this->assertRaw(l(t('Cancel'), 'admin/commerce/config/taxes/types'), t('Cancel link is present')); + $this->assertFieldById('edit-tax-type-title', $this->tax_type['title'], 'Title field corresponds with tax type'); + $this->assertText($this->tax_type['name'], 'Machine name field corresponds with tax type'); + $this->assertFieldById('edit-tax-type-display-title', $this->tax_type['display_title'], 'Display title field corresponds with tax type'); + $this->assertFieldById('edit-submit', t('Save tax type'), '\'Save tax rate\' button is present'); + $this->assertFieldById('edit-delete', t('Delete tax type'), 'Delete button is present'); + $this->assertRaw(l(t('Cancel'), 'admin/commerce/config/taxes/types'), 'Cancel link is present'); // Modify the tax type and save it. $edit = array( @@ -447,18 +447,18 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalPost(NULL, $edit, t('Save tax type')); // Check the url after edit and if the values have been loaded. - $this->assertTrue($this->url == url('admin/commerce/config/taxes/types', array('absolute' => TRUE)), t('After saving a tax type we are in the list of tax types')); - $this->assertText($edit['tax_type[title]'], t('Title of the tax type is present in the tax types listing')); - $this->assertText($edit['tax_type[description]'], t('Description of the tax type is present in the tax types listing')); - $this->assertText(t('Tax type saved.'), t('\'Tax type saved\' message is displayed')); + $this->assertTrue($this->url == url('admin/commerce/config/taxes/types', array('absolute' => TRUE)), 'After saving a tax type we are in the list of tax types'); + $this->assertText($edit['tax_type[title]'], 'Title of the tax type is present in the tax types listing'); + $this->assertText($edit['tax_type[description]'], 'Description of the tax type is present in the tax types listing'); + $this->assertText(t('Tax type saved.'), '\'Tax type saved\' message is displayed'); // Check in database if the tax rate has been correctly modified. commerce_tax_types_reset(); $tax_type = commerce_tax_type_load($this->tax_type['name']); - $this->assertTrue($tax_type['title'] == $edit['tax_type[title]'], t('Title of the tax type has been correctly modified in the database')); - $this->assertTrue($tax_type['display_title'] == $edit['tax_type[display_title]'], t('Display title of the tax type has been correctly modified in the database')); - $this->assertTrue($tax_type['description'] == $edit['tax_type[description]'], t('Description of the tax type has been correctly modified in the database')); - $this->assertTrue($tax_type['display_inclusive'] == $edit['tax_type[display_inclusive]'], t('Display inclusive option of the tax type has been correctly modified in the database')); + $this->assertTrue($tax_type['title'] == $edit['tax_type[title]'], 'Title of the tax type has been correctly modified in the database'); + $this->assertTrue($tax_type['display_title'] == $edit['tax_type[display_title]'], 'Display title of the tax type has been correctly modified in the database'); + $this->assertTrue($tax_type['description'] == $edit['tax_type[description]'], 'Description of the tax type has been correctly modified in the database'); + $this->assertTrue($tax_type['display_inclusive'] == $edit['tax_type[display_inclusive]'], 'Display inclusive option of the tax type has been correctly modified in the database'); } /** @@ -472,7 +472,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/config/workflow/rules/reaction/manage/commerce_tax_type_' . $this->tax_type['name']); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the')); + $this->assertResponse(403, 'Normal user is not able to access the'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -481,10 +481,10 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/config/workflow/rules/reaction/manage/commerce_tax_type_' . $this->tax_type['name']); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the')); + $this->assertResponse(200, 'Store admin user can access the'); // Add a condition - $this->assertLink(t('Add condition'), 0, t('Add condition link is present')); + $this->assertLink(t('Add condition'), 0, 'Add condition link is present'); $this->clickLink(t('Add condition')); // Select a basic condition as at this step we're only testing if the @@ -495,8 +495,8 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { // Check that after saving the url is correct and the condition has been // added. - $this->assertTrue($this->url == url('admin/config/workflow/rules/reaction/manage/commerce_tax_type_' . $this->tax_type['name'], array('absolute' => TRUE)), t('After adding a new condition component the landing page is the edit components one')); - $this->assertText(t('Entity is of type'), t('Condition was added correctly')); + $this->assertTrue($this->url == url('admin/config/workflow/rules/reaction/manage/commerce_tax_type_' . $this->tax_type['name'], array('absolute' => TRUE)), 'After adding a new condition component the landing page is the edit components one'); + $this->assertText(t('Entity is of type'), 'Condition was added correctly'); } /** @@ -510,7 +510,7 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types/' . strtr($this->tax_type['name'], '_', '-') . '/delete'); // It should return a 403. - $this->assertResponse(403, t('Normal user is not able to access the tax type delete page')); + $this->assertResponse(403, 'Normal user is not able to access the tax type delete page'); // Login with store admin user. $this->drupalLogin($this->store_admin); @@ -519,26 +519,26 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types/' . strtr($this->tax_type['name'], '_', '-') . '/delete'); // It should return a 200. - $this->assertResponse(200, t('Store admin user can access the tax type delete page')); + $this->assertResponse(200, 'Store admin user can access the tax type delete page'); // Check the integrity of the tax type delete confirmation form. $this->pass('Test the tax type delete confirmation form:'); - $this->assertTitle(t('Are you sure you want to delete the !title tax type?', array('!title' => $this->tax_type['title'])) . ' | Drupal', t('The confirmation message for deleting a tax type is displayed')); - $this->assertText(t('This action cannot be undone'), t('A warning notifying the user about the action can\'t be undone is displayed.')); - $this->assertFieldById('edit-submit', t('Delete'), t('Delete button is present')); - $this->assertText(t('Cancel'), t('Cancel is present')); + $this->assertTitle(t('Are you sure you want to delete the !title tax type?', array('!title' => $this->tax_type['title'])) . ' | Drupal', 'The confirmation message for deleting a tax type is displayed'); + $this->assertText(t('This action cannot be undone'), 'A warning notifying the user about the action can\'t be undone is displayed.'); + $this->assertFieldById('edit-submit', t('Delete'), 'Delete button is present'); + $this->assertText(t('Cancel'), 'Cancel is present'); // Delete the tax type. $this->drupalPost(NULL, array(), t('Delete')); // Check the url after deleting and if the tax type has been deleted in // database. - $this->assertTrue($this->url == url('admin/commerce/config/taxes/types', array('absolute' => TRUE)), t('Landing page after deleting a tax type is the tax types listing page')); - $this->assertRaw(t('The tax type %title has been deleted.', array('%title' => $this->tax_type['title'])), t('\'Tax type has been deleted\' message is displayed')); + $this->assertTrue($this->url == url('admin/commerce/config/taxes/types', array('absolute' => TRUE)), 'Landing page after deleting a tax type is the tax types listing page'); + $this->assertRaw(t('The tax type %title has been deleted.', array('%title' => $this->tax_type['title'])), '\'Tax type has been deleted\' message is displayed'); commerce_tax_types_reset(); $tax_type = commerce_tax_rate_load($this->tax_type['name']); - $this->assertTrue(empty($tax_type), t('Tax type is correctly deleted from database')); + $this->assertTrue(empty($tax_type), 'Tax type is correctly deleted from database'); } /** @@ -555,8 +555,8 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet('admin/commerce/config/taxes/types/' . strtr($this->tax_type['name'], '_', '-') . '/delete'); // Check that the tax can't be deleted as it has a rate associated to it. - $this->assertTitle(t('Cannot delete the !title tax type', array('!title' => $this->tax_type['title'])) . ' | Drupal', t('Page title for tax type deletion with rates associated to it is correct')); - $this->assertText(t('There is a tax rate of this type. It cannot be deleted.'), t('A message that prevents user from deleting a tax type with rates associated to it is displayed')); + $this->assertTitle(t('Cannot delete the !title tax type', array('!title' => $this->tax_type['title'])) . ' | Drupal', 'Page title for tax type deletion with rates associated to it is correct'); + $this->assertText(t('There is a tax rate of this type. It cannot be deleted.'), 'A message that prevents user from deleting a tax type with rates associated to it is displayed'); } /** @@ -583,11 +583,11 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $order_data = $order_wrapper->commerce_order_total->value(); $components = commerce_price_component_load($order_data, $tax_rate['price_component']); $tax_component = reset($components); - $this->assertFalse(empty($tax_component), t('Tax is applied in the order')); + $this->assertFalse(empty($tax_component), 'Tax is applied in the order'); // Tax should be applied in Checkout Review with the correct quantity. - $this->assertText($tax_rate['display_title'], t('Tax appears in the order summary')); - $this->assertText(trim(commerce_currency_format($order_data['amount'], $order_data['currency_code'])), t('Tax amount applied appears in the order summary')); + $this->assertText($tax_rate['display_title'], 'Tax appears in the order summary'); + $this->assertText(trim(commerce_currency_format($order_data['amount'], $order_data['currency_code'])), 'Tax amount applied appears in the order summary'); } /** @@ -613,10 +613,10 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $products = commerce_product_load_multiple(array($product->product_id), array(), TRUE); $product = reset($products); $price_component = commerce_product_calculate_sell_price($product); - $this->assertText(trim(commerce_currency_format($price_component['amount'], $price_component['currency_code'])), t('Amount with taxes corresponds with the amount displayed in the product display page')); + $this->assertText(trim(commerce_currency_format($price_component['amount'], $price_component['currency_code'])), 'Amount with taxes corresponds with the amount displayed in the product display page'); $components = commerce_price_component_load($price_component, $tax_rate['price_component']); $tax_component = reset($components); - $this->assertFalse(empty($tax_component), t('Tax component is set in the product.')); + $this->assertFalse(empty($tax_component), 'Tax component is set in the product.'); } /** @@ -648,11 +648,11 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $products = commerce_product_load_multiple(array($product->product_id), array(), TRUE); $product = reset($products); $price_component = commerce_product_calculate_sell_price($product); - $this->assertText(trim(commerce_currency_format($price_component['amount'], $price_component['currency_code'])), t('Amount with taxes included corresponds with the amount displayed in the product display page')); + $this->assertText(trim(commerce_currency_format($price_component['amount'], $price_component['currency_code'])), 'Amount with taxes included corresponds with the amount displayed in the product display page'); $components = commerce_price_component_load($price_component, $tax_rate['price_component']); $tax_component = reset($components); - $this->assertFalse(empty($tax_component), t('Tax component is set in the product.')); - $this->assertTrue($tax_component['included'], t('Tax component is configured to be included in the price')); + $this->assertFalse(empty($tax_component), 'Tax component is set in the product.'); + $this->assertTrue($tax_component['included'], 'Tax component is configured to be included in the price'); } /** @@ -684,14 +684,14 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $this->drupalGet($this->checkout_url); // As the condition is impossible to match, tax rate shouldn't be applied. - $this->assertNoText($tax_rate['display_title'], t('Tax rate doesn\'t match the conditions and is not present in the cart review pane.')); + $this->assertNoText($tax_rate['display_title'], 'Tax rate doesn\'t match the conditions and is not present in the cart review pane.'); // Also check it at database level. $orders = commerce_order_load_multiple(array($order->order_id), array(), TRUE); $order = reset($orders); $order_wrapper = entity_metadata_wrapper('commerce_order', $order); $components = commerce_price_component_load($order_wrapper->commerce_order_total->value(), $tax_rate['price_component']); $tax_component = reset($components); - $this->assertTrue(empty($tax_component), t('Tax component is not set in the order.')); + $this->assertTrue(empty($tax_component), 'Tax component is not set in the order.'); } /** @@ -721,8 +721,8 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $tax_component = reset($components); // Check the taxes applied. - $this->assertText($tax_rate['display_title'], t('Tax display title is displayed in the user view of an order.')); - $this->assertText(trim(commerce_currency_format($tax_component['price']['amount'], $tax_component['price']['currency_code'])), t('Tax amount is displayed in the user view of an order.')); + $this->assertText($tax_rate['display_title'], 'Tax display title is displayed in the user view of an order.'); + $this->assertText(trim(commerce_currency_format($tax_component['price']['amount'], $tax_component['price']['currency_code'])), 'Tax amount is displayed in the user view of an order.'); } /** @@ -755,8 +755,8 @@ class CommerceTaxUIAdminTest extends CommerceBaseTestCase { $tax_component = reset($components); // Check the taxes applied. - $this->assertText($tax_rate['display_title'], t('Tax display title is displayed in the admin view of an order.')); - $this->assertText(trim(commerce_currency_format($tax_component['price']['amount'], $tax_component['price']['currency_code'])), t('Tax amount is displayed in the admin view of an order.')); + $this->assertText($tax_rate['display_title'], 'Tax display title is displayed in the admin view of an order.'); + $this->assertText(trim(commerce_currency_format($tax_component['price']['amount'], $tax_component['price']['currency_code'])), 'Tax amount is displayed in the admin view of an order.'); } }