jenkins-bot has submitted this change and it was merged.

Change subject: TestingGenericAdapter can do normal validation, not just fakey
......................................................................


TestingGenericAdapter can do normal validation, not just fakey

Change-Id: I611d29479a247f94a3beadb390fcbd4d7cd3502b
---
M DonationInterface.php
M tests/GatewayPageTest.php
A tests/includes/TestingGatewayPage.php
M tests/includes/test_gateway/TestingGenericAdapter.php
4 files changed, 26 insertions(+), 14 deletions(-)

Approvals:
  Ejegg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/DonationInterface.php b/DonationInterface.php
index 3cbb6a1..460d448 100644
--- a/DonationInterface.php
+++ b/DonationInterface.php
@@ -1119,6 +1119,7 @@
        $wgAutoloadClasses['TestingAdyenAdapter'] = $testDir . 
'includes/test_gateway/TestingAdyenAdapter.php';
        $wgAutoloadClasses['TestingAmazonAdapter'] = $testDir . 
'includes/test_gateway/TestingAmazonAdapter.php';
        $wgAutoloadClasses['TestingAmazonGateway'] = $testDir . 
'includes/test_page/TestingAmazonGateway.php';
+       $wgAutoloadClasses['TestingGatewayPage'] = $testDir . 
'includes/TestingGatewayPage.php';
        $wgAutoloadClasses['TestingGenericAdapter'] = $testDir . 
'includes/test_gateway/TestingGenericAdapter.php';
        $wgAutoloadClasses['TestingGlobalCollectAdapter'] = $testDir . 
'includes/test_gateway/TestingGlobalCollectAdapter.php';
        $wgAutoloadClasses['TestingGlobalCollectGateway'] = $testDir . 
'includes/test_page/TestingGlobalCollectGateway.php';
diff --git a/tests/GatewayPageTest.php b/tests/GatewayPageTest.php
index 0a9a0d0..7dabd1a 100644
--- a/tests/GatewayPageTest.php
+++ b/tests/GatewayPageTest.php
@@ -16,15 +16,6 @@
  *
  */
 
-class TestingGatewayPage extends GatewayPage {
-       public function __construct() {
-               //nothing!
-       }
-       protected function handleRequest() {
-               //also nothing!
-       }
-}
-
 /**
  * @group Fundraising
  * @group DonationInterface
@@ -53,6 +44,8 @@
 
                $this->page->validateForm();
 
+               $this->assertTrue( $this->adapter->validatedOK() );
+
                $manualErrors = $this->adapter->getManualErrors();
                $msg = $this->page->msg( 
'donate_interface-fallback-currency-notice', 'USD' )->text();
                $this->assertEquals( $msg, $manualErrors['general'] );
@@ -78,6 +71,8 @@
 
                $this->page->validateForm();
 
+               $this->assertTrue( $this->adapter->validatedOK() );
+
                $manualErrors = $this->adapter->getManualErrors();
                $this->assertEquals( null, $manualErrors['general'] );
                $this->assertEquals( 100, 
$this->adapter->getData_Unstaged_Escaped( 'amount' ) );
diff --git a/tests/includes/TestingGatewayPage.php 
b/tests/includes/TestingGatewayPage.php
new file mode 100644
index 0000000..79872d6
--- /dev/null
+++ b/tests/includes/TestingGatewayPage.php
@@ -0,0 +1,10 @@
+<?php
+
+class TestingGatewayPage extends GatewayPage {
+       public function __construct() {
+               //nothing!
+       }
+       protected function handleRequest() {
+               //also nothing!
+       }
+}
diff --git a/tests/includes/test_gateway/TestingGenericAdapter.php 
b/tests/includes/test_gateway/TestingGenericAdapter.php
index 1a348ed..c92d3b8 100644
--- a/tests/includes/test_gateway/TestingGenericAdapter.php
+++ b/tests/includes/test_gateway/TestingGenericAdapter.php
@@ -21,16 +21,22 @@
  */
 class TestingGenericAdapter extends GatewayAdapter {
 
+       /**
+        * A list of fake errors that is returned each time revalidate() is 
called.
+        */
        public $errorsForRevalidate = array();
+
        public $revalidateCount = 0;
        public static $fakeGlobals = array();
 
        public function revalidate($check_not_empty = array()) {
-               $fakeErrors = 
$this->errorsForRevalidate[$this->revalidateCount];
-               if ( $fakeErrors !== null ) {
-                       $this->revalidateCount++;
-                       $this->setValidationErrors( $fakeErrors );
-                       return empty( $fakeErrors );
+               if ( $this->errorsForRevalidate ) {
+                       $fakeErrors = 
$this->errorsForRevalidate[$this->revalidateCount];
+                       if ( $fakeErrors !== null ) {
+                               $this->revalidateCount++;
+                               $this->setValidationErrors( $fakeErrors );
+                               return empty( $fakeErrors );
+                       }
                }
                return parent::revalidate($check_not_empty);
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/184009
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I611d29479a247f94a3beadb390fcbd4d7cd3502b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to