Skip to content

Commit ebb8a03

Browse files
authored
Merge pull request #34 from ionutcalara/master
Updated tests and version
2 parents 0863fe8 + ce0696c commit ebb8a03

File tree

6 files changed

+37
-70
lines changed

6 files changed

+37
-70
lines changed

paylikepayment.zip

-4.42 KB
Binary file not shown.

paylikepayment/controllers/front/paymentreturn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author DerikonDevelopment <ionut@derikon.com>
55
* @copyright Copyright (c) permanent, DerikonDevelopment
66
* @license Addons PrestaShop license limitation
7-
* @version 1.1.1
7+
* @version 1.2.0
88
* @link http://www.derikon.com/
99
*
1010
*/

paylikepayment/paylikepayment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author DerikonDevelopment <ionut@derikon.com>
55
* @copyright Copyright (c) permanent, DerikonDevelopment
66
* @license Addons PrestaShop license limitation
7-
* @version 1.1.1
7+
* @version 1.2.0
88
* @link http://www.derikon.com/
99
*
1010
*/
@@ -28,7 +28,7 @@ class PaylikePayment extends PaymentModule {
2828
public function __construct() {
2929
$this->name = 'paylikepayment';
3030
$this->tab = 'payments_gateways';
31-
$this->version = '1.1.1';
31+
$this->version = '1.2.0';
3232
$this->author = 'DerikonDevelopment';
3333
$this->bootstrap = true;
3434

tests/PrestashopQuickTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PrestashopQuickTest extends AbstractTestCase {
2626
public function testUsdPaymentBeforeOrderInstant() {
2727
$this->runner = new PrestashopRunner( $this );
2828
$this->runner->ready( array(
29-
'capture_mode' => 'instant',
29+
'capture_mode' => 'delayed',
3030
)
3131
);
3232
}

tests/PrestashopRunner.php

Lines changed: 16 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,6 @@ private function outputVersions() {
157157
}
158158

159159

160-
/**
161-
* @throws NoSuchElementException
162-
* @throws TimeOutException
163-
*/
164-
public function changeDecimal() {
165-
$this->goToPage( 'wp-admin/admin.php?page=wc-settings', '#select2-prestashop_currency-container' );
166-
$this->type( '#prestashop_price_decimal_sep', '.' );
167-
}
168-
169-
/**
170-
*
171-
*/
172-
public function submitAdmin() {
173-
$this->click( '#module_form_submit_btn' );
174-
}
175-
176160
/**
177161
* @throws NoSuchElementException
178162
* @throws TimeOutException
@@ -189,25 +173,13 @@ private function directPayment() {
189173
$this->finalPaylike();
190174
$this->selectOrder();
191175
if ( $this->capture_mode == 'delayed' ) {
192-
$this->checkNoCaptureWarning();
193176
$this->capture();
194177
} else {
195178
$this->refund();
196179
}
197180

198181
}
199182

200-
/**
201-
* @throws NoSuchElementException
202-
* @throws TimeOutException
203-
* @throws UnexpectedTagNameException
204-
*/
205-
public function checkNoCaptureWarning() {
206-
$this->moveOrderToStatus( 'Payment accepted' );
207-
$text = $this->pluckElement( '.history-status tr td', 1 )->getText();
208-
$messages = explode( "\n", $text );
209-
$this->main_test->assertEquals( 'Remote payment accepted', $messages[0], "Not captured warning" );
210-
}
211183

212184
/**
213185
* @param $status
@@ -216,10 +188,8 @@ public function checkNoCaptureWarning() {
216188
* @throws UnexpectedTagNameException
217189
*/
218190
public function moveOrderToStatus( $status ) {
219-
$this->click( '#id_order_state_chosen' );
220-
$this->type( ".chosen-search input", $status );
221-
$this->pressEnter();
222-
$this->click( 'submitState' );
191+
$this->selectValueByLabel('#update_order_status_action_input',$status);
192+
$this->click( '#update_order_status_action_btn' );
223193
}
224194

225195
/**
@@ -228,17 +198,9 @@ public function moveOrderToStatus( $status ) {
228198
* @throws UnexpectedTagNameException
229199
*/
230200
public function capture() {
231-
$this->selectValue( "#paylike_action", "capture" );
232-
$this->click( '#submit_paylike_action' );
233-
$this->waitElementDisappear( ".margin-form #submit_paylike_action.disabled" );
234-
$this->waitForPageReload( function () {
235-
}, 5000 );
236-
$text = $this->pluckElement( '.history-status tr td', 1 )->getText();
237-
if ( $text == 'Delivered' || $text == 'Delivered' ) {
238-
$text = $this->pluckElement( '.history-status tr td', 1 )->getText();
239-
}
240-
$messages = explode( "\n", $text );
241-
$this->main_test->assertEquals( 'Delivered', $messages[0], "Delivered" );
201+
$this->moveOrderToStatus( 'Delivered' );
202+
$text = $this->pluckElement( '.tab-content #historyTabContent tr td', 0 )->getText();
203+
$this->main_test->assertEquals( 'Delivered', $text, "Payment captured" );
242204
}
243205

244206
/**
@@ -364,10 +326,9 @@ public function popupPaylike() {
364326
* @throws TimeOutException
365327
*/
366328
public function selectOrder() {
367-
$this->goToPage( "/index.php?controller=AdminOrders", '.btn-continue', true );
368-
$this->click( ".btn-continue" );
369-
$this->waitForElement( '.text-right .btn-group .icon-search-plus' );
370-
$this->click( '.text-right .btn-group .icon-search-plus' );
329+
$this->goToPage( "/index.php?controller=AdminOrders", '#page-header-desc-configuration-add', true );
330+
$this->waitForElement( '.text-right .btn[data-original-title="View"]' );
331+
$this->click( '.text-right .btn[data-original-title="View"]' );
371332
}
372333

373334
/**
@@ -376,25 +337,14 @@ public function selectOrder() {
376337
* @throws UnexpectedTagNameException
377338
*/
378339
public function refund() {
379-
$this->waitForElement( '#paylike_action' );
380-
$this->selectValue( "#paylike_action", "refund" );
381-
$refund = preg_match_all( '!\d+!', $this->getText( '.amount strong' ), $refund_value );
382-
$refund_value = $refund_value[0];
383-
$this->type( 'paylike_amount_to_refund', $refund_value[0] );
384-
$this->click( '#submit_paylike_action' );
385-
try {
386-
$this->waitElementDisappear( ".margin-form #submit_paylike_action.disabled" );
387-
} catch ( NoSuchElementException $e ) {
388-
// the element may have already dissapeared
389-
}
390-
$this->waitForPageReload( function () {
391-
}, 5000 );
392-
$text = $this->pluckElement( '.history-status tr td', 1 )->getText();
393-
if ( $text == 'Refunded' || $text == 'Refunded' ) {
394-
$text = $this->pluckElement( '.history-status tr td', 1 )->getText();
395-
}
396-
$messages = explode( "\n", $text );
397-
$this->main_test->assertEquals( 'Refunded', $messages[0], "Refunded" );
340+
$this->waitForElement( '.partial-refund-display' );
341+
$this->click('.partial-refund-display');
342+
$this->type( '.refund-quantity', 1 );
343+
$this->click( '#cancel_product_save' );
344+
345+
$this->waitForElement( '.alert.alert-success' );
346+
$text = $this->pluckElement( '.alert.alert-success', 0 )->getText();
347+
$this->main_test->assertEquals( 'Paylike: Transaction successfully Refunded.', $text, "Refunded" );
398348
}
399349

400350
/**

tests/PrestashopTestHelper.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,23 @@ public function selectValue($selectQuery, $value) {
149149
return $this;
150150
}
151151

152+
/**
153+
* set value from select by option label
154+
*
155+
* @param $selectQuery
156+
* @param $value
157+
*
158+
* @return $this
159+
* @throws NoSuchElementException
160+
* @throws \Facebook\WebDriver\Exception\UnexpectedTagNameException
161+
*/
162+
public function selectValueByLabel($selectQuery, $value) {
163+
$select = new WebDriverSelect($this->find($selectQuery));
164+
$select->selectByVisibleText($value);
165+
166+
return $this;
167+
}
168+
152169
/**
153170
* @param $selectQuery
154171
* @param $value

0 commit comments

Comments
 (0)