Property changes on: trunk/extensions/DonationInterface/tests/TestConfiguration.php.dist |
___________________________________________________________________ |
Deleted: svn:eol-style |
1 | 1 | - native |
Index: trunk/extensions/DonationInterface/tests/Adapter/GlobalCollect/BankTransferTestCase.php |
— | — | @@ -62,27 +62,97 @@ |
63 | 63 | IBAN |
64 | 64 | CountryDescription |
65 | 65 | Notes |
66 | | - We do not need to have donor information stored on our side yet as long as it is sent to Global Collect |
| 66 | + We do not need to have donor information stored on our side yet as long as it is sent to Global Collect |
67 | 67 | */ |
68 | 68 | |
69 | 69 | /** |
70 | | - * Copied from Katie's test code |
| 70 | + * testbuildRequestXML |
| 71 | + * |
| 72 | + * @todo |
| 73 | + * - there are many cases to this that need to be developed. |
| 74 | + * - Do not consider this a complete test! |
| 75 | + * |
| 76 | + * @covers GatewayAdapter::__construct |
| 77 | + * @covers GatewayAdapter::do_transaction |
| 78 | + * @covers GatewayAdapter::buildRequestXML |
| 79 | + * @covers GatewayAdapter::getData |
71 | 80 | */ |
72 | 81 | public function testbuildRequestXML() { |
73 | 82 | |
74 | | - $this->markTestIncomplete( TESTS_MESSAGE_NOT_IMPLEMENTED ); |
| 83 | + global $wgGlobalCollectGatewayTest; |
| 84 | + global $wgRequest; |
| 85 | + |
| 86 | + $wgGlobalCollectGatewayTest = true; |
75 | 87 | |
76 | | - return; |
| 88 | + $_SERVER = array(); |
77 | 89 | |
78 | | - $gateway = new TestAdapter(); |
79 | | - $gateway->publicCurrentTransaction( 'Test1' ); |
80 | | - $built = $gateway->buildRequestXML(); |
81 | | - $expected = '<?xml version="1.0"?>' . "\n"; |
82 | | - $expected .= '<XML><REQUEST><ACTION>Donate</ACTION><ACCOUNT><MERCHANTID>128</MERCHANTID><PASSWORD>k4ftw</PASSWORD><VERSION>3.2</VERSION><RETURNURL>http://' . TESTS_HOSTNAME . '/index.php/Donate-thanks/en</RETURNURL></ACCOUNT><DONATION><DONOR>Tester Testington</DONOR><AMOUNT>35000</AMOUNT><CURRENCYCODE>USD</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>US</COUNTRYCODE></DONATION></REQUEST></XML>' . "\n"; |
83 | | - $this->assertEquals($built, $expected, "The constructed XML for transaction type Test1 does not match our expected."); |
| 90 | + $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; |
| 91 | + $_SERVER['HTTP_HOST'] = TESTS_HOSTNAME; |
| 92 | + $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME; |
| 93 | + $_SERVER['REQUEST_URI'] = '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount'; |
| 94 | + |
| 95 | + |
| 96 | + $options = array(); |
84 | 97 | |
| 98 | + $options['test'] = true; |
| 99 | + $transactionType = 'BANK_TRANSFER'; |
| 100 | + |
| 101 | + $amount = 350; |
| 102 | + |
| 103 | + $options['postDefaults'] = array( |
| 104 | + 'returnTitle' => true, |
| 105 | + 'returnTo' => 'http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGatewayResult', |
| 106 | + ); |
| 107 | + |
| 108 | + $options['testData'] = array( |
| 109 | + 'amount' => $amount, |
| 110 | + 'transaction_type' => $transactionType, |
| 111 | + 'email' => TESTS_EMAIL, |
| 112 | + 'fname' => 'Testy', |
| 113 | + 'lname' => 'Testerton', |
| 114 | + 'street' => '123 Happy Street', |
| 115 | + 'city' => 'Barcelona', |
| 116 | + 'state' => 'XX', |
| 117 | + 'zip' => '', |
| 118 | + 'country' => 'ES', |
| 119 | + //'size' => 'small', |
| 120 | + 'currency' => 'EUR', |
| 121 | + 'payment_method' => '', |
| 122 | + //'order_id' => '5038287830', |
| 123 | + //'i_order_id' => '1234567890', |
| 124 | + 'numAttempt' => 0, |
| 125 | + 'referrer' => 'http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount', |
| 126 | + 'utm_source' => '..gc_bt', |
| 127 | + 'utm_medium' => null, |
| 128 | + 'utm_campaign' => null, |
| 129 | + 'language' => 'en', |
| 130 | + 'comment-option' => '', |
| 131 | + 'comment' => '', |
| 132 | + 'email-opt' => 1, |
| 133 | + 'test_string' => '', |
| 134 | + 'token' => '', |
| 135 | + 'contribution_tracking_id' => '', |
| 136 | + 'data_hash' => '', |
| 137 | + 'action' => '', |
| 138 | + 'gateway' => 'globalcollect', |
| 139 | + 'owa_session' => '', |
| 140 | + 'owa_ref' => 'http://localhost/defaultTestData', |
| 141 | + 'transaction_type' => '', // Used by GlobalCollect for payment types |
| 142 | + ); |
| 143 | + |
| 144 | + $gateway = new GlobalCollectAdapter( $options ); |
| 145 | + |
| 146 | + $result = $gateway->do_transaction( $transactionType ); |
| 147 | + |
| 148 | + $request = trim( $gateway->buildRequestXML() ); |
| 149 | + |
| 150 | + $orderId = $gateway->getData( 'order_id' ); |
| 151 | + |
| 152 | + $expected = '<?xml version="1.0"?>' . "\n"; |
| 153 | + $expected .= '<XML><REQUEST><ACTION>INSERT_ORDERWITHPAYMENT</ACTION><META><MERCHANTID>6570</MERCHANTID><VERSION>1.0</VERSION></META><PARAMS><ORDER><ORDERID>' . $orderId . '</ORDERID><AMOUNT>' . $amount * 100 . '</AMOUNT><CURRENCYCODE>EUR</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>ES</COUNTRYCODE><MERCHANTREFERENCE>' . $orderId . '</MERCHANTREFERENCE></ORDER><PAYMENT><PAYMENTPRODUCTID>11</PAYMENTPRODUCTID><AMOUNT>35000</AMOUNT><CURRENCYCODE>EUR</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>ES</COUNTRYCODE><HOSTEDINDICATOR>1</HOSTEDINDICATOR><RETURNURL>http://wikimedia-fundraising-1.17.localhost.wikimedia.org/index.php/Special:GlobalCollectGatewayResult?order_id=' . $orderId . '</RETURNURL><FIRSTNAME>Testy</FIRSTNAME><SURNAME>Testerton</SURNAME><STREET>123 Happy Street</STREET><CITY>Barcelona</CITY><STATE>XX</STATE><EMAIL>jpostlethwaite@wikimedia.org</EMAIL></PAYMENT></PARAMS></REQUEST></XML>'; |
| 154 | + //$expected .= '<XML><REQUEST><ACTION>Donate</ACTION><ACCOUNT><MERCHANTID>128</MERCHANTID><PASSWORD>k4ftw</PASSWORD><VERSION>3.2</VERSION><RETURNURL>http://' . TESTS_HOSTNAME . '/index.php/Donate-thanks/en</RETURNURL></ACCOUNT><DONATION><DONOR>Tester Testington</DONOR><AMOUNT>35000</AMOUNT><CURRENCYCODE>USD</CURRENCYCODE><LANGUAGECODE>en</LANGUAGECODE><COUNTRYCODE>US</COUNTRYCODE></DONATION></REQUEST></XML>' . "\n"; |
| 155 | + $this->assertEquals($request, $expected, 'The constructed XML for transaction type [' . $transactionType . '] does not match our expected.'); |
85 | 156 | } |
86 | | - |
87 | 157 | |
88 | 158 | /** |
89 | 159 | * testRequestHasRequiredFields |
— | — | @@ -110,8 +180,8 @@ |
111 | 181 | public function testSendToGlobalCollect() { |
112 | 182 | $this->markTestIncomplete( TESTS_MESSAGE_NOT_IMPLEMENTED ); |
113 | 183 | |
114 | | - //global $wgContLang, $wgAuth, $wgMemc, $wgRequest, $wgUser, $wgServer; |
115 | 184 | global $wgGlobalCollectGatewayTest; |
| 185 | + global $wgRequest; |
116 | 186 | |
117 | 187 | $wgGlobalCollectGatewayTest = true; |
118 | 188 | |
— | — | @@ -121,51 +191,35 @@ |
122 | 192 | $_SERVER['HTTP_HOST'] = TESTS_HOSTNAME; |
123 | 193 | $_SERVER['SERVER_NAME'] = TESTS_HOSTNAME; |
124 | 194 | $_SERVER['REQUEST_URI'] = '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount'; |
125 | | - |
126 | | - /** |
127 | | - * @see WebStart.php |
128 | | - */ |
129 | | - require_once TESTS_WEB_ROOT . '/includes/WebStart.php'; |
130 | 195 | |
131 | 196 | $options = array(); |
132 | 197 | |
133 | 198 | $options['test'] = true; |
134 | | - $options['transactionType'] = 'BANK_TRANSFER'; |
| 199 | + $transactionType = 'BANK_TRANSFER'; |
135 | 200 | |
136 | 201 | $options['postDefaults'] = array( |
137 | 202 | 'returnTitle' => true, |
138 | 203 | 'returnTo' => 'http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGatewayResult', |
139 | 204 | ); |
| 205 | + |
| 206 | + $amount = 350; |
140 | 207 | |
141 | 208 | $options['testData'] = array( |
142 | | - 'amount' => "35", |
143 | | - 'amountOther' => '', |
144 | | - 'email' => 'test@example.com', |
145 | | - 'fname' => 'Tester', |
146 | | - 'mname' => 'T.', |
147 | | - 'lname' => 'Testington', |
148 | | - 'street' => '548 Market St.', |
149 | | - 'city' => 'San Francisco', |
150 | | - 'state' => 'CA', |
151 | | - 'zip' => '94104', |
152 | | - 'country' => 'US', |
153 | | - 'fname2' => 'Testy', |
154 | | - 'lname2' => 'Testerson', |
155 | | - 'street2' => '123 Telegraph Ave.', |
156 | | - 'city2' => 'Berkeley', |
157 | | - 'state2' => 'CA', |
158 | | - 'zip2' => '94703', |
159 | | - 'country2' => 'US', |
160 | | - 'size' => 'small', |
161 | | - 'premium_language' => 'es', |
162 | | - //'card_num' => TESTS_CREDIT_CARDS_AMEREICAN_EXPRESS_VALID_CARD, |
163 | | - //'card_type' => 'american', |
164 | | - //'expiration' => date( 'my', strtotime( '+1 year 1 month' ) ), |
165 | | - //'cvv' => '001', |
166 | | - 'currency' => 'USD', |
| 209 | + 'amount' => $amount, |
| 210 | + 'transaction_type' => $transactionType, |
| 211 | + 'email' => TESTS_EMAIL, |
| 212 | + 'fname' => 'Testy', |
| 213 | + 'lname' => 'Testerton', |
| 214 | + 'street' => '123 Happy Street', |
| 215 | + 'city' => 'Barcelona', |
| 216 | + 'state' => 'XX', |
| 217 | + 'zip' => '', |
| 218 | + 'country' => 'ES', |
| 219 | + //'size' => 'small', |
| 220 | + 'currency' => 'EUR', |
167 | 221 | 'payment_method' => '', |
168 | | - 'order_id' => '1234567890', |
169 | | - 'i_order_id' => '1234567890', |
| 222 | + //'order_id' => '5038287830', |
| 223 | + //'i_order_id' => '1234567890', |
170 | 224 | 'numAttempt' => 0, |
171 | 225 | 'referrer' => 'http://' . TESTS_HOSTNAME . '/index.php/Special:GlobalCollectGateway?form_name=TwoStepAmount', |
172 | 226 | 'utm_source' => '..gc_bt', |
— | — | @@ -187,7 +241,9 @@ |
188 | 242 | ); |
189 | 243 | |
190 | 244 | $gateway = new GlobalCollectAdapter( $options ); |
191 | | - return $gateway->do_transaction( $options['transactionType'] ); |
| 245 | + $result = $gateway->do_transaction( $transactionType ); |
| 246 | + |
| 247 | + $this->assertTrue( $result ); |
192 | 248 | } |
193 | 249 | } |
194 | 250 | |
Index: trunk/extensions/DonationInterface/tests/TestHelper.php |
— | — | @@ -37,7 +37,22 @@ |
38 | 38 | */ |
39 | 39 | error_reporting( E_ALL | E_STRICT ); |
40 | 40 | |
| 41 | +/** |
| 42 | + * TESTS_WEB_ROOT |
| 43 | + * |
| 44 | + * This is similar to $IP, the installation path in Mediawiki. |
| 45 | + */ |
| 46 | +define( 'TESTS_WEB_ROOT', dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
41 | 47 | |
| 48 | +$IP = TESTS_WEB_ROOT; |
| 49 | + |
| 50 | +/* |
| 51 | + * Required files for unit testing. |
| 52 | + */ |
| 53 | +require_once( TESTS_WEB_ROOT . '/includes/SpecialPage.php' ); |
| 54 | +require_once( TESTS_WEB_ROOT . '/includes/Title.php' ); |
| 55 | +require_once( TESTS_WEB_ROOT . '/includes/Exception.php' ); |
| 56 | + |
42 | 57 | /** |
43 | 58 | * @see DonationData |
44 | 59 | */ |
— | — | @@ -49,6 +64,16 @@ |
50 | 65 | require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'gateway_common/gateway.adapter.php'; |
51 | 66 | |
52 | 67 | /** |
| 68 | + * @see GatewayForm |
| 69 | + */ |
| 70 | +require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'gateway_common/GatewayForm.php'; |
| 71 | + |
| 72 | +/** |
| 73 | + * @see extras/extras.body.php |
| 74 | + */ |
| 75 | +require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'extras/extras.body.php'; |
| 76 | + |
| 77 | +/** |
53 | 78 | * @see GlobalCollectAdapter |
54 | 79 | */ |
55 | 80 | require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'globalcollect_gateway/globalcollect.adapter.php'; |
— | — | @@ -58,19 +83,52 @@ |
59 | 84 | */ |
60 | 85 | require_once dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR . 'ContributionTracking/ContributionTracking.processor.php'; |
61 | 86 | |
| 87 | + |
| 88 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 89 | + define( 'MEDIAWIKI', 1 ); |
| 90 | +} |
| 91 | + |
| 92 | +/* |
| 93 | + * Unit tests are run from the command line. |
| 94 | + * |
| 95 | + * It should be confirmed that this will not affect other tests such as Selenium. |
| 96 | + */ |
| 97 | +//$wgCommandLineMode = true; |
| 98 | +//$wgCanonicalServer = true; |
| 99 | + |
62 | 100 | /** |
63 | | - * TESTS_WEB_ROOT |
| 101 | + * Initializing the global $_SERVER for unit testing. This array does not exist |
| 102 | + * on the CLI. |
64 | 103 | * |
65 | | - * This is similar to $IP, the installation path in Mediawiki. |
| 104 | + * You may customize this variable in TestConfiguration.php. |
| 105 | + * |
| 106 | + * @todo |
| 107 | + * - make this default more general and customizable. |
| 108 | + * |
| 109 | + * @var array $_SERVER |
66 | 110 | */ |
67 | | -define( 'TESTS_WEB_ROOT', dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
| 111 | +$_SERVER = array ( 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1', 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_COOKIE' => 'mediawiki_fundraising_117_session=f2rc8vv6av1o324qodvinqlpi1', 'HTTP_IF_MODIFIED_SINCE' => 'Fri, 14 Oct 2011 20:18:45 GMT', 'PATH' => '/usr/bin:/bin:/usr/sbin:/sbin', 'SERVER_SIGNATURE' => ' |
| 112 | +Apache/2.2.19 (Unix) DAV/2 PHP/5.3.7 Server at localhost Port 80 |
| 113 | +', 'SERVER_SOFTWARE' => 'Apache/2.2.19 (Unix) DAV/2 PHP/5.3.7', 'SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/dev/null', 'SERVER_ADMIN' => 'no-reply@example.org', 'SCRIPT_FILENAME' => '/dev/null/index.php', 'REMOTE_PORT' => '62747', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', 'REQUEST_URI' => '/', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'REQUEST_TIME' => 1318890010, ); |
68 | 114 | |
| 115 | +// Initialize session for unit testing |
| 116 | +$_SESSION = isset( $_SESSION ) ? $_SESSION : array(); |
| 117 | + |
69 | 118 | /* |
70 | | - * Unit tests are run from the command line. |
| 119 | + * Required files for unit testing. |
71 | 120 | * |
72 | | - * It should be confirmed that this will not affect other tests such as Selenium. |
| 121 | + * These files need to be required after the above code. Do not move. |
73 | 122 | */ |
74 | | -$wgCommandLineMode = true; |
| 123 | +require_once( TESTS_WEB_ROOT . '/includes/Defines.php' ); |
| 124 | +require_once( TESTS_WEB_ROOT . '/LocalSettings.php' ); |
| 125 | +require_once( TESTS_WEB_ROOT . '/includes/WebRequest.php' ); |
| 126 | +require_once( TESTS_WEB_ROOT . '/includes/GlobalFunctions.php' ); |
| 127 | +require_once( TESTS_WEB_ROOT . '/includes/HttpFunctions.php' ); |
| 128 | +require_once( TESTS_WEB_ROOT . '/includes/db/Database.php' ); |
| 129 | +require_once( TESTS_WEB_ROOT . '/includes/db/DatabaseMysql.php' ); |
| 130 | +require_once( TESTS_WEB_ROOT . '/includes/Profiler.php' ); |
| 131 | +$request = $_SERVER; |
| 132 | +$wgRequest = new FauxRequest( $request ); |
75 | 133 | |
76 | 134 | /* |
77 | 135 | * Load the user-defined test configuration file, if it exists; otherwise, load |
— | — | @@ -82,3 +140,11 @@ |
83 | 141 | require_once 'TestConfiguration.php.dist'; |
84 | 142 | } |
85 | 143 | |
| 144 | +/* |
| 145 | + * Customize the server variable options. |
| 146 | + */ |
| 147 | +$_SERVER['HTTP_HOST'] = TESTS_HOSTNAME; |
| 148 | +$_SERVER['SERVER_NAME'] = TESTS_HOSTNAME; |
| 149 | +$_SERVER['SERVER_NAME'] = TESTS_WEB_ROOT; |
| 150 | +$_SERVER['SERVER_ADMIN'] = TESTS_EMAIL; |
| 151 | + |
Index: trunk/extensions/DonationInterface/tests/unittest.conf.dist |
— | — | @@ -0,0 +1,90 @@ |
| 2 | +#!/bin/sh |
| 3 | +################################################################################ |
| 4 | +# |
| 5 | +# Wikimedia Foundation |
| 6 | +# |
| 7 | +# LICENSE |
| 8 | +# |
| 9 | +# This program is free software; you can redistribute it and/or modify |
| 10 | +# it under the terms of the GNU General Public License as published by |
| 11 | +# the Free Software Foundation; either version 2 of the License, or |
| 12 | +# (at your option) any later version. |
| 13 | +# |
| 14 | +# This program is distributed in the hope that it will be useful, |
| 15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | +# GNU General Public License for more details. |
| 18 | +# |
| 19 | +# |
| 20 | +# @category UnitTesting |
| 21 | +# @package Fundraising_Miscellaneous |
| 22 | +# @license http://www.gnu.org/copyleft/gpl.html GNU GENERAL PUBLIC LICENSE |
| 23 | +# @since r462 |
| 24 | +# @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org> |
| 25 | +# |
| 26 | +################################################################################ |
| 27 | +# |
| 28 | +# This is the distributed configuration file. If you need to make changes to |
| 29 | +# these settings, copy this file to this directory and remove the ".dist" |
| 30 | +# extension. |
| 31 | +# |
| 32 | +################################################################################ |
| 33 | +# |
| 34 | +# @var string $UNITTEST_HOSTNAME The hostname to the webserver. |
| 35 | +# |
| 36 | +: ${UNITTEST_HOSTNAME:="localhost"} |
| 37 | +# |
| 38 | +# @var string $UNITTEST_URL The url to the webserver. You need the trailing |
| 39 | +# slash. |
| 40 | +# |
| 41 | +: ${UNITTEST_URL:="http://localhost/queue_handling/tests/"} |
| 42 | +# |
| 43 | +# @var string $PHPUNIT If phpunit.php is not within your shell $PATH, you may |
| 44 | +# specify the full path here. |
| 45 | +# |
| 46 | +: ${PHPUNIT:="phpunit.php"} |
| 47 | +# |
| 48 | +# @var string $PHPUNIT_OPTS By default, all testing will be run in verbose mode. |
| 49 | +# |
| 50 | +: ${PHPUNIT_OPTS:="--verbose"} |
| 51 | +# |
| 52 | +# @var string $PHPUNIT_LIST_GROUPS Specify the relative path to the file in |
| 53 | +# which you want to list groups designated by the doctag @group |
| 54 | +# |
| 55 | +: ${PHPUNIT_LIST_GROUPS:"=AllTests.php"} |
| 56 | +# |
| 57 | +# @var string $PHPUNIT_FILE Specify the relative path to the test in which you |
| 58 | +# want to run. You need to omit the ".php" extension. |
| 59 | +# |
| 60 | +: ${PHPUNIT_FILE:="AllTests"} |
| 61 | +# |
| 62 | +# @var string $PHPUNIT_COVERAGE_HTML The relative path to the code coverage |
| 63 | +# html directory |
| 64 | +# |
| 65 | +# This is where code coverage will be saved if the flag -ch is passed. If you wish to specify a full path, use: |
| 66 | +# --coverage-html "/some/absolute/path" |
| 67 | +# |
| 68 | +# These directories will need to exist, they will not be created. |
| 69 | +# |
| 70 | +: ${PHPUNIT_COVERAGE_HTML:="logs/coverage/html"} |
| 71 | +# |
| 72 | +# @var string $PHPUNIT_COVERAGE_CLOVER The relative path to the code coverage |
| 73 | +# clover directory |
| 74 | +# |
| 75 | +# This is where code coverage will be saved if the flag -ch is passed. If you wish to specify a full path, use: |
| 76 | +# --coverage-clover "/some/absolute/path" |
| 77 | +# |
| 78 | +# These directories will need to exist, they will not be created. |
| 79 | +# |
| 80 | +: ${PHPUNIT_COVERAGE_CLOVER:="logs/coverage/clover/index.xml"} |
| 81 | +# |
| 82 | +# @var string $PHPUNIT_TESTDOX_HTML The relative path to the testdox output html |
| 83 | +# directory. It is okay to put this the same directory as html coverage. |
| 84 | +# |
| 85 | +# This is where testdox will be saved if the flag -tdh is passed. If you wish to specify a full path, use: |
| 86 | +# --testdox-html "/some/absolute/path" |
| 87 | +# |
| 88 | +# These directories will need to exist, they will not be created. |
| 89 | +# |
| 90 | +: ${PHPUNIT_TESTDOX_HTML:="logs/coverage/html/testdox.html"} |
| 91 | + |
Index: trunk/extensions/DonationInterface/tests/phpunit.xml |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +<phpunit> |
| 3 | + <filter> |
| 4 | + <whitelist addUncoveredFilesFromWhitelist="false"> |
| 5 | + <directory suffix=".php">../</directory> |
| 6 | + <exclude> |
| 7 | + <directory suffix=".php">../extras</directory> |
| 8 | + <directory suffix=".php">../tests</directory> |
| 9 | + <directory suffix=".php">../../../includes</directory> |
| 10 | + </exclude> |
| 11 | + </whitelist> |
| 12 | + </filter> |
| 13 | +</phpunit> |
Property changes on: trunk/extensions/DonationInterface/tests/phpunit.xml |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 14 | + native |
Added: svn:mime-type |
2 | 15 | + text/xml |
Added: svn:keywords |
3 | 16 | + Author Date HeadURL Header Id Revision |
Index: trunk/extensions/DonationInterface/tests/unittest.sh |
— | — | @@ -0,0 +1,289 @@ |
| 2 | +#!/bin/sh |
| 3 | +################################################################################ |
| 4 | +# |
| 5 | +# Wikimedia Foundation |
| 6 | +# |
| 7 | +# LICENSE |
| 8 | +# |
| 9 | +# This program is free software; you can redistribute it and/or modify |
| 10 | +# it under the terms of the GNU General Public License as published by |
| 11 | +# the Free Software Foundation; either version 2 of the License, or |
| 12 | +# (at your option) any later version. |
| 13 | +# |
| 14 | +# This program is distributed in the hope that it will be useful, |
| 15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | +# GNU General Public License for more details. |
| 18 | +# |
| 19 | +# |
| 20 | +# @category UnitTesting |
| 21 | +# @package Fundraising_Miscellaneous |
| 22 | +# @license http://www.gnu.org/copyleft/gpl.html GNU GENERAL PUBLIC LICENSE |
| 23 | +# @since r462 |
| 24 | +# @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org> |
| 25 | +# |
| 26 | +################################################################################ |
| 27 | +# |
| 28 | +# The script: |
| 29 | +# |
| 30 | +# unittest.sh - Launch PHPUnit for specific test group(s). |
| 31 | +# |
| 32 | +################################################################################ |
| 33 | +# |
| 34 | +# Debugging the script |
| 35 | +# |
| 36 | +# The set -x option causes sh to print each command to standard error before |
| 37 | +# executing it. Since this can generate a lot of output, you may want to turn |
| 38 | +# tracing on just before the section that you want to trace, and turn it off |
| 39 | +# immediately afterward: |
| 40 | +#set -x |
| 41 | +# |
| 42 | +################################################################################ |
| 43 | +# |
| 44 | +# help() |
| 45 | +# |
| 46 | +################################################################################ |
| 47 | +help() |
| 48 | +{ |
| 49 | + cat <<HELP |
| 50 | + |
| 51 | +NAME |
| 52 | + unittest.sh -- Run phpunit |
| 53 | + |
| 54 | +SYNOPSIS |
| 55 | + $0 |
| 56 | + [-h | --help] [help] |
| 57 | + [-l | --list-groups] ["relative/path/to/file"] |
| 58 | + |
| 59 | + [-d | --debug ] |
| 60 | + [-nc | --no-configuration ] |
| 61 | + |
| 62 | + [-cc | --coverage-clover ["/full/path/to/index.xml"] ] |
| 63 | + [-ch | --coverage-html ["/full/path/to/folder"] ] |
| 64 | + [-tdh | --testdox-html ["/full/path/to/testdox.html"] ] |
| 65 | + |
| 66 | +DESCRIPTION |
| 67 | + The unittest.sh script is designed to facilitate running phpunit. |
| 68 | + |
| 69 | +EXAMPLES |
| 70 | + |
| 71 | + # List all groups available for testing |
| 72 | + |
| 73 | + $0 -l |
| 74 | + |
| 75 | + # List all groups available for testing in the file PostTestCase |
| 76 | + |
| 77 | + $0 -l GlobalCollect/AllTests.php |
| 78 | + |
| 79 | + # List all groups available for testing in the file PostTestCase |
| 80 | + |
| 81 | + $0 -l GlobalCollect/PostTestCase.php |
| 82 | + |
| 83 | + # Run unit testing with html code coverage report to default path |
| 84 | + |
| 85 | + $0 -ch |
| 86 | + |
| 87 | + # Run unit testing with html code coverage report |
| 88 | + |
| 89 | + $0 -ch GlobalCollect/AllTests |
| 90 | + |
| 91 | + # Run unit testing with clover code coverage report to default path |
| 92 | + |
| 93 | + $0 -cc |
| 94 | + |
| 95 | + # Run unit testing with clover code coverage report |
| 96 | + |
| 97 | + $0 -cc GlobalCollect/AllTests |
| 98 | + |
| 99 | + # Generate testdox report |
| 100 | + |
| 101 | + $0 -tdh |
| 102 | + $0 --testdox-html |
| 103 | + |
| 104 | + # Turn on PHPUnit debugging |
| 105 | + |
| 106 | + $0 -d |
| 107 | + $0 --debug |
| 108 | + |
| 109 | + # Ignore the local phpunit.xml file |
| 110 | + |
| 111 | + $0 -nc |
| 112 | + $0 --no-configuration |
| 113 | + |
| 114 | +HELP |
| 115 | + exit 0 |
| 116 | +} |
| 117 | +################################################################################ |
| 118 | +# |
| 119 | +# load_configuration() |
| 120 | +# |
| 121 | +# Load the configuration file |
| 122 | +# |
| 123 | +################################################################################ |
| 124 | +load_configuration() |
| 125 | +{ |
| 126 | + CONFIGURATION_FILE="unittest.conf" |
| 127 | + |
| 128 | + # Load the custom configuration file if it exists |
| 129 | + if [ -f "${CONFIGURATION_FILE}" ]; then |
| 130 | + source ${CONFIGURATION_FILE}; |
| 131 | + else |
| 132 | + |
| 133 | + # Load the default configuration file |
| 134 | + CONFIGURATION_FILE="${CONFIGURATION_FILE}.dist" |
| 135 | + |
| 136 | + if [ -f "${CONFIGURATION_FILE}" ]; then |
| 137 | + source ${CONFIGURATION_FILE}; |
| 138 | + else |
| 139 | + echo "The default configuration file (${CONFIGURATION_FILE}) is missing from: `pwd`" |
| 140 | + exit 1; |
| 141 | + fi |
| 142 | + fi |
| 143 | +} |
| 144 | +################################################################################ |
| 145 | +# |
| 146 | +# Begin execution of script |
| 147 | +# |
| 148 | +################################################################################ |
| 149 | +# Run help if needed. |
| 150 | +[ -z "${1}" ] && help |
| 151 | +[ "${1}" = "-h" ] && help |
| 152 | +[ "${1}" = "help" ] && help |
| 153 | + |
| 154 | +# |
| 155 | +# @var string $UNITTEST_DIRECTORY This is the relative path to the |
| 156 | +# configuration file. |
| 157 | +UNITTEST_DIRECTORY="`dirname $0`/" |
| 158 | + |
| 159 | +# Change to script directory to keep path variables consistent. |
| 160 | +cd ${UNITTEST_DIRECTORY} |
| 161 | + |
| 162 | +load_configuration |
| 163 | +################################################################################ |
| 164 | +# |
| 165 | +# @var string $PHPUNIT_COVERAGE_HTML_LINK The link to html code coverage |
| 166 | +# |
| 167 | +PHPUNIT_COVERAGE_HTML_LINK=${UNITTEST_URL} |
| 168 | +# |
| 169 | +# @var string $PHPUNIT_COVERAGE_CLOVER_LINK The link to clover code coverage |
| 170 | +# |
| 171 | +PHPUNIT_COVERAGE_CLOVER_LINK=${UNITTEST_URL} |
| 172 | +# |
| 173 | +# @var string $PHPUNIT_COVERAGE_TESTDOX_LINK The link to testdox code coverage |
| 174 | +# |
| 175 | +PHPUNIT_COVERAGE_TESTDOX_LINK=${UNITTEST_URL} |
| 176 | +################################################################################ |
| 177 | + |
| 178 | +################################################################################ |
| 179 | +# |
| 180 | +# Loop through options to pass to phpunit.php |
| 181 | +# |
| 182 | +################################################################################ |
| 183 | +while [ -n "$1" ] ; do |
| 184 | + |
| 185 | + case "$1" in |
| 186 | + |
| 187 | + # list-groups |
| 188 | + -l|--list-groups) |
| 189 | + PHPUNIT_LIST_GROUPS="--list-groups" |
| 190 | + break ;; |
| 191 | + |
| 192 | + # coverage-html |
| 193 | + -ch) |
| 194 | + PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --coverage-html ${PHPUNIT_COVERAGE_HTML}" |
| 195 | + PHPUNIT_COVERAGE_HTML_LINK="${PHPUNIT_COVERAGE_HTML_LINK}${PHPUNIT_COVERAGE_HTML}" |
| 196 | + shift 1 ;; |
| 197 | + |
| 198 | + --coverage-html) |
| 199 | + PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --coverage-html $2" |
| 200 | + PHPUNIT_COVERAGE_HTML_LINK="${PHPUNIT_COVERAGE_HTML_LINK}$2" |
| 201 | + shift ;; |
| 202 | + |
| 203 | + # coverage-clover |
| 204 | + -cc) |
| 205 | + PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --coverage-clover ${PHPUNIT_COVERAGE_CLOVER}" |
| 206 | + PHPUNIT_COVERAGE_CLOVER_LINK="${PHPUNIT_COVERAGE_CLOVER_LINK}${PHPUNIT_COVERAGE_CLOVER}" |
| 207 | + shift 1 ;; |
| 208 | + |
| 209 | + --coverage-clover) |
| 210 | + PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --coverage-clover $2" |
| 211 | + PHPUNIT_COVERAGE_CLOVER_LINK="${PHPUNIT_COVERAGE_CLOVER_LINK}$2" |
| 212 | + shift 2 ;; |
| 213 | + |
| 214 | + # no-configuration |
| 215 | + -nc|--no-configuration) |
| 216 | + PHPUNIT_OPTS="${PHPUNIT_OPTS} --no-configuration" |
| 217 | + shift ;; |
| 218 | + |
| 219 | + # testdox-html |
| 220 | + -tdh) |
| 221 | + PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --testdox-html ${PHPUNIT_TESTDOX_HTML}" |
| 222 | + PHPUNIT_COVERAGE_TESTDOX_LINK="${PHPUNIT_COVERAGE_TESTDOX_LINK}${PHPUNIT_TESTDOX_HTML}" |
| 223 | + shift 1 ;; |
| 224 | + |
| 225 | + --testdox-html) |
| 226 | + PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --testdox-html $2" |
| 227 | + PHPUNIT_COVERAGE_TESTDOX_LINK="${PHPUNIT_COVERAGE_TESTDOX_LINK}$2" |
| 228 | + shift 2 ;; |
| 229 | + |
| 230 | + # debug |
| 231 | + -d|--debug) |
| 232 | + PHPUNIT_OPTS="${PHPUNIT_OPTS} --debug" |
| 233 | + shift ;; |
| 234 | + |
| 235 | + # file |
| 236 | + -f|--file) |
| 237 | + PHPUNIT_FILE="$2" |
| 238 | + shift 2 ;; |
| 239 | + |
| 240 | + # All groups |
| 241 | + ALL|all|MAX|max) |
| 242 | + PHPUNIT_GROUPS="" |
| 243 | + break ;; |
| 244 | + |
| 245 | + *) |
| 246 | + PHPUNIT_GROUPS="${PHPUNIT_GROUPS:+"$PHPUNIT_GROUPS,"}$1" |
| 247 | + shift ;; |
| 248 | + esac |
| 249 | +done |
| 250 | +################################################################################ |
| 251 | +# |
| 252 | +# Information statements |
| 253 | +# |
| 254 | +################################################################################ |
| 255 | +echo "" |
| 256 | + |
| 257 | +echo "SCRIPT PATH:\n\n${PATH}" |
| 258 | + |
| 259 | +echo "" |
| 260 | + |
| 261 | +echo "PWD:\n\n`pwd`" |
| 262 | + |
| 263 | +echo "" |
| 264 | + |
| 265 | +COMMAND_OPTIONS="${PHPUNIT_OPTS} ${PHPUNIT_LIST_GROUPS} ${PHPUNIT_COVERAGE} ${PHPUNIT_GROUPS:+--group $PHPUNIT_GROUPS} ${PHPUNIT_FILE}" |
| 266 | +echo "COMMAND:\n\n${PHPUNIT} ${COMMAND_OPTIONS}" |
| 267 | + |
| 268 | +echo "" |
| 269 | + |
| 270 | +echo "HTML code coverage link:\n\n${PHPUNIT_COVERAGE_HTML_LINK}" |
| 271 | + |
| 272 | +echo "" |
| 273 | + |
| 274 | +echo "Clover code coverage link:\n\n${PHPUNIT_COVERAGE_CLOVER_LINK}" |
| 275 | + |
| 276 | +echo "" |
| 277 | + |
| 278 | +echo "Testdox code coverage link:\n\n${PHPUNIT_COVERAGE_TESTDOX_LINK}" |
| 279 | + |
| 280 | +echo "" |
| 281 | + |
| 282 | +################################################################################ |
| 283 | +# Debugging |
| 284 | +# |
| 285 | +# The set -n option causes sh to read the script but not execute any commands. |
| 286 | +# This is useful for checking syntax. |
| 287 | +#set -n |
| 288 | +################################################################################ |
| 289 | + |
| 290 | +${PHPUNIT} ${PHPUNIT_OPTS} ${COMMAND_OPTIONS} |
Property changes on: trunk/extensions/DonationInterface/tests/unittest.sh |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 291 | + native |
Added: svn:executable |
2 | 292 | + * |
Added: svn:keywords |
3 | 293 | + Author Date HeadURL Header Id Revision |
Property changes on: trunk/extensions/DonationInterface/tests |
___________________________________________________________________ |
Added: svn:mergeinfo |
4 | 294 | Merged /branches/fundraising/extensions/DonationInterface/tests:r100122-100281 |
Modified: svn:ignore |
5 | 295 | - TestConfiguration.php |
6 | 296 | + TestConfiguration.php |
unittest.conf |