public function CommercePaymentUITest::testCommercePaymentMethodsAdministration in Commerce Core 7
Test payment method rules conditions.
File
- modules/
payment/ tests/ commerce_payment_ui.test, line 181 - Functional tests for the commerce payment module user interface.
Class
- CommercePaymentUITest
- Test payment user interface.
Code
public function testCommercePaymentMethodsAdministration() {
// Log in as store administrator user.
$this
->drupalLogin($this->store_admin);
// 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'));
// Go to edit example payment rule.
$this
->clickLink(t('Example payment'));
// Adding a new condition.
$this
->clickLink(t('Add condition'));
// 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
->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
->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'));
// 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'));
// 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'));
// 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'));
}