Révision b858700c
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/commerce/modules/payment/tests/commerce_payment_ui.test | ||
---|---|---|
97 | 97 |
|
98 | 98 |
$this->assertText('Example payment', t('Example payment method pane is present')); |
99 | 99 |
|
100 |
// Test validation messages not filling any information. |
|
101 |
$this->drupalPost(NULL, array(), t('Continue to next step')); |
|
102 |
|
|
103 |
// Get all panes from the system to get their forms. |
|
104 |
$panes = commerce_checkout_panes(); |
|
105 |
|
|
106 |
// Check the validation message for the example payment pane. |
|
107 |
$callback = commerce_checkout_pane_callback($panes['commerce_payment'], 'checkout_form'); |
|
108 |
$pane_form = drupal_get_form($callback, $panes['commerce_payment'], $this->order); |
|
109 |
foreach (element_children($pane_form['payment_details']) as $key) { |
|
110 |
if ($pane_form['payment_details'][$key]['#required']) { |
|
111 |
$this->assertText(t('!pane_message field is required', array('!pane_message' => $pane_form['payment_details'][$key]['#title'])), t('Check required payment pane message')); |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
// Test payment information validation. Payment example module name field |
|
116 |
// will fail for single character value. |
|
117 |
$this->drupalPost(NULL, array('commerce_payment[payment_details][name]' => $this->randomName(1)), t('Continue to next step')); |
|
118 |
$this->assertTitle(t('Review order') . ' | Drupal', t('We should still be on review order page')); |
|
119 |
$this->assertText(t('You must enter a name two or more characters long.'), t('Validation error message found on the page')); |
|
120 |
|
|
121 | 100 |
// Finish checkout process. |
122 |
$this->drupalPost(NULL, array('commerce_payment[payment_details][name]' => $this->randomName()), t('Continue to next step'));
|
|
101 |
$this->drupalPost(NULL, array(), t('Continue to next step')); |
|
123 | 102 |
|
124 | 103 |
// Load payment to check its status. |
125 | 104 |
$payment = commerce_payment_transaction_load_multiple(array(), array('order_id' => $this->order->order_id), TRUE); |
... | ... | |
154 | 133 |
$this->drupalPostAJAX(NULL, array('payment_method' => 'commerce_payment_example|commerce_payment_commerce_payment_example'), array('op' => t('Add payment'))); |
155 | 134 |
$this->assertFieldByXPath("//input[starts-with(@id, 'edit-amount')]", NULL, t('Amount field is present')); |
156 | 135 |
$this->assertFieldByXPath("//select[starts-with(@id, 'edit-currency-code')]", NULL, t('Currency code field is present')); |
157 |
$this->assertFieldByXPath("//input[starts-with(@id, 'edit-payment-details-name')]", NULL, t('Name text field from payment example module is present'));
|
|
136 |
$this->assertFieldByXPath("//input[starts-with(@id, 'edit-payment-details-credit-card-number')]", NULL, t('Credit card number field from payment example module is present'));
|
|
158 | 137 |
$this->assertFieldByXPath("//input[starts-with(@id, 'edit-submit')]", NULL, t('Save button is present')); |
159 | 138 |
$payment_amount = intval($balance['amount'] / 2); |
160 | 139 |
$post_data = array( |
161 | 140 |
'amount' => (commerce_currency_amount_to_decimal($payment_amount, $balance['currency_code'])), |
162 | 141 |
'currency_code' => 'USD', |
163 |
'payment_details[name]' => $this->randomName(), |
|
164 | 142 |
); |
165 | 143 |
$this->drupalPost(NULL, $post_data, t('Save')); |
166 | 144 |
|
... | ... | |
179 | 157 |
$this->drupalPostAJAX(NULL, array('payment_method' => 'commerce_payment_example|commerce_payment_commerce_payment_example'), array('op' => t('Add payment'))); |
180 | 158 |
$this->assertFieldByXPath("//input[starts-with(@id, 'edit-amount')]", NULL, t('Amount field is present')); |
181 | 159 |
$this->assertFieldByXPath("//select[starts-with(@id, 'edit-currency-code')]", NULL, t('Currency code field is present')); |
182 |
$this->assertFieldByXPath("//input[starts-with(@id, 'edit-payment-details-name')]", NULL, t('Name text field from payment example module is present'));
|
|
160 |
$this->assertFieldByXPath("//input[starts-with(@id, 'edit-payment-details-credit-card-number')]", NULL, t('Credit card number field from payment example module is present'));
|
|
183 | 161 |
$this->assertFieldByXPath("//input[starts-with(@id, 'edit-submit')]", NULL, t('Save button is present')); |
184 | 162 |
$post_data = array( |
185 | 163 |
'amount' => commerce_currency_amount_to_decimal($new_balance['amount'], $new_balance['currency_code']), |
186 | 164 |
'currency_code' => 'USD', |
187 |
'payment_details[name]' => $this->randomName(), |
|
188 | 165 |
); |
189 | 166 |
$this->drupalPost(NULL, $post_data, t('Save')); |
190 | 167 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules