Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit ae52c6b

Browse files
author
Luke Shepard
committed
[ Upgrading php-openid test framework to use PHPUnit 3.3 ]
Reviewed By: Will Norris The set of tests assumes PHPUnit 2.3, which conflicts with my environment setup. I think PHPUnit 3.3 is pretty widespread now, and under active maintenance (latest rev 4/10/2009). There's a few changes included here. I did a few mostly automated code transformations: replace "PHPUnit_TestCase" "PHPUnit_Framework_TestCase" replace "PHPUnit_TestSuite" "PHPUnit_Framework_TestSuite" removed all require_once "PHPUnit.php" - they are unnecessary. "call by reference" is now deprecated, so changed "&$" to "$" I also made a few changes to admin/testtext.php and Tests/TestDriver.php to accomodate the new syntax. Note that this just upgrades the framework; it does not guarantee that all tests pass. I'll submit future diffs to fix or disable failing unit tests. I wasn't able to get the tests running with the previous version, so I don't know if these have always been failing. I doubt that the github has automatically running unit tests, but if so then we'll have to make sure that the central repo is running the same version of PHPUnit.
1 parent 5a96dc7 commit ae52c6b

37 files changed

+215
-250
lines changed

Auth/OpenID/AX.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ function getExtensionArgs($request=null)
888888
$ax_args['update_url'] = $update_url;
889889
}
890890

891-
Auth_OpenID::update(&$ax_args, $kv_args);
891+
Auth_OpenID::update($ax_args, $kv_args);
892892

893893
return $ax_args;
894894
}
@@ -960,7 +960,7 @@ function getExtensionArgs($aliases=null)
960960
{
961961
$ax_args = $this->_newArgs();
962962
$kv_args = $this->_getExtensionKVArgs($aliases);
963-
Auth_OpenID::update(&$ax_args, $kv_args);
963+
Auth_OpenID::update($ax_args, $kv_args);
964964
return $ax_args;
965965
}
966966
}

Auth/OpenID/Discover.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ function Auth_OpenID_discoverWithYadis($uri, &$fetcher,
433433
$openid_services = array();
434434

435435
$response = call_user_func_array($discover_function,
436-
array($uri, &$fetcher));
436+
array($uri, $fetcher));
437437

438438
$yadis_url = $response->normalized_uri;
439439
$yadis_services = array();
@@ -460,7 +460,7 @@ function Auth_OpenID_discoverWithYadis($uri, &$fetcher,
460460
}
461461

462462
$openid_services = call_user_func_array($endpoint_filter,
463-
array(&$openid_services));
463+
array($openid_services));
464464

465465
return array($yadis_url, $openid_services);
466466
}

Auth/Yadis/ParanoidHTTPFetcher.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ function get($url, $extra_headers = null)
109109
}
110110

111111
curl_setopt($c, CURLOPT_WRITEFUNCTION,
112-
array(&$this, "_writeData"));
112+
array($this, "_writeData"));
113113
curl_setopt($c, CURLOPT_HEADERFUNCTION,
114-
array(&$this, "_writeHeader"));
114+
array($this, "_writeHeader"));
115115

116116
if ($extra_headers) {
117117
curl_setopt($c, CURLOPT_HTTPHEADER, $extra_headers);
@@ -190,7 +190,7 @@ function post($url, $body, $extra_headers = null)
190190
curl_setopt($c, CURLOPT_TIMEOUT, $this->timeout);
191191
curl_setopt($c, CURLOPT_URL, $url);
192192
curl_setopt($c, CURLOPT_WRITEFUNCTION,
193-
array(&$this, "_writeData"));
193+
array($this, "_writeData"));
194194

195195
curl_exec($c);
196196

Tests/Auth/OpenID/AX.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* Tests for the attribute exchange extension module
55
*/
66

7-
require_once "PHPUnit.php";
87
require_once "Auth/OpenID/AX.php";
98
require_once "Auth/OpenID/Message.php";
109
require_once "Auth/OpenID/Consumer.php";
@@ -19,7 +18,7 @@ function getExtensionArgs()
1918
}
2019
}
2120

22-
class AXMessageTest extends PHPUnit_TestCase {
21+
class AXMessageTest extends PHPUnit_Framework_TestCase {
2322
function setUp()
2423
{
2524
$this->bax = new BogusAXMessage();
@@ -48,7 +47,7 @@ function test_checkMode_newArgs()
4847
}
4948
}
5049

51-
class AttrInfoTest extends PHPUnit_TestCase {
50+
class AttrInfoTest extends PHPUnit_Framework_TestCase {
5251
function test_construct()
5352
{
5453
$type_uri = 'a uri';
@@ -61,7 +60,7 @@ function test_construct()
6160
}
6261
}
6362

64-
class ToTypeURIsTest extends PHPUnit_TestCase {
63+
class ToTypeURIsTest extends PHPUnit_Framework_TestCase {
6564
function setUp()
6665
{
6766
$this->aliases = new Auth_OpenID_NamespaceMap();
@@ -107,7 +106,7 @@ function test_two()
107106
}
108107
}
109108

110-
class ParseAXValuesTest extends PHPUnit_TestCase {
109+
class ParseAXValuesTest extends PHPUnit_Framework_TestCase {
111110
function failUnlessAXKeyError($ax_args)
112111
{
113112
$msg = new Auth_OpenID_AX_KeyValueMessage();
@@ -250,7 +249,7 @@ function test_singletonValue()
250249
}
251250
}
252251

253-
class FetchRequestTest extends PHPUnit_TestCase {
252+
class FetchRequestTest extends PHPUnit_Framework_TestCase {
254253
function setUp()
255254
{
256255
$this->msg = new Auth_OpenID_AX_FetchRequest();
@@ -523,7 +522,7 @@ function FauxEndpoint() {
523522
}
524523
}
525524

526-
class FetchResponseTest extends PHPUnit_TestCase {
525+
class FetchResponseTest extends PHPUnit_Framework_TestCase {
527526
function setUp()
528527
{
529528
$this->msg = new Auth_OpenID_AX_FetchResponse();
@@ -638,9 +637,9 @@ function test_get()
638637

639638
function test_fromSuccessResponseWithoutExtension()
640639
{
641-
$args = array(
640+
$args = array(
642641
'mode' => 'id_res',
643-
'ns' => Auth_OpenID_OPENID2_NS
642+
'ns' => Auth_OpenID_OPENID2_NS
644643
);
645644
$sf = array();
646645
foreach (array_keys($args) as $k) {
@@ -655,7 +654,7 @@ function test_fromSuccessResponseWithoutExtension()
655654

656655
function test_fromSuccessResponseWithoutData()
657656
{
658-
$args = array(
657+
$args = array(
659658
'mode' => 'id_res',
660659
'ns' => Auth_OpenID_OPENID2_NS,
661660
'ns.ax' => Auth_OpenID_AX_NS_URI,
@@ -677,7 +676,7 @@ function test_fromSuccessResponse()
677676
$name = "ziggy";
678677
$value = "stardust";
679678
$uri = "http://david.bowie.name/";
680-
$args = array(
679+
$args = array(
681680
'mode' => 'id_res',
682681
'ns' => Auth_OpenID_OPENID2_NS,
683682
'ns.ax' => Auth_OpenID_AX_NS_URI,
@@ -702,7 +701,7 @@ function test_fromSuccessResponse()
702701
}
703702
}
704703

705-
class StoreRequestTest extends PHPUnit_TestCase {
704+
class StoreRequestTest extends PHPUnit_Framework_TestCase {
706705
function setUp()
707706
{
708707
$this->msg = new Auth_OpenID_AX_StoreRequest();
@@ -742,7 +741,7 @@ function test_getExtensionArgs_nonempty()
742741
}
743742
}
744743

745-
class StoreResponseTest extends PHPUnit_TestCase {
744+
class StoreResponseTest extends PHPUnit_Framework_TestCase {
746745
function test_success()
747746
{
748747
$msg = new Auth_OpenID_AX_StoreResponse();
@@ -772,7 +771,7 @@ function test_fail_msg()
772771
}
773772
}
774773

775-
class Tests_Auth_OpenID_AX extends PHPUnit_TestSuite {
774+
class Tests_Auth_OpenID_AX extends PHPUnit_Framework_TestSuite {
776775
function getName()
777776
{
778777
return "Tests_Auth_OpenID_AX";

Tests/Auth/OpenID/Association.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache
1414
*/
1515

16-
require_once 'PHPUnit.php';
1716
require_once 'Auth/OpenID/Association.php';
1817

19-
class Tests_Auth_OpenID_Association extends PHPUnit_TestCase {
18+
class Tests_Auth_OpenID_Association extends PHPUnit_Framework_TestCase {
2019
function test_me()
2120
{
2221
$issued = time();

Tests/Auth/OpenID/AssociationResponse.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
require_once "PHPUnit.php";
43
require_once "Tests/Auth/OpenID/TestUtil.php";
54
require_once "Tests/Auth/OpenID/MemStore.php";
65

@@ -39,7 +38,7 @@ function mkAssocResponse($keys)
3938
return Auth_OpenID_Message::fromOpenIDArgs($args);
4039
}
4140

42-
class Tests_Auth_OpenID_AssociationResponse extends PHPUnit_TestCase {
41+
class Tests_Auth_OpenID_AssociationResponse extends PHPUnit_Framework_TestCase {
4342
function setUp()
4443
{
4544
$this->store = new Tests_Auth_OpenID_MemStore();

Tests/Auth/OpenID/AuthRequest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
require_once 'PHPUnit.php';
4-
53
require_once 'Tests/Auth/OpenID/TestUtil.php';
64

75
require_once 'Auth/OpenID/Association.php';
@@ -283,7 +281,7 @@ class TestAuthRequestOpenID2Immediate extends TestAuthRequestOpenID2 {
283281
var $expected_mode = 'checkid_immediate';
284282
}
285283

286-
class Tests_Auth_OpenID_AuthRequest extends PHPUnit_TestSuite {
284+
class Tests_Auth_OpenID_AuthRequest extends PHPUnit_Framework_TestSuite {
287285

288286
function getName()
289287
{

Tests/Auth/OpenID/BigMath.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache
1414
*/
1515

16-
require_once 'PHPUnit.php';
1716
require_once 'Auth/OpenID/BigMath.php';
1817
require_once 'Tests/Auth/OpenID/TestUtil.php';
1918

20-
class Tests_Auth_OpenID_BinLongConvertRnd extends PHPUnit_TestCase {
19+
class Tests_Auth_OpenID_BinLongConvertRnd extends PHPUnit_Framework_TestCase {
2120
var $lib;
2221
var $max;
2322

24-
function Tests_Auth_OpenID_BinLongConvertRnd(&$lib, $max)
23+
function Tests_Auth_OpenID_BinLongConvertRnd($lib, $max)
2524
{
2625
$this->lib =& $lib;
2726
$this->max = $max;
@@ -41,12 +40,12 @@ function runTest()
4140
}
4241
}
4342

44-
class Tests_Auth_OpenID_BinLongConvert extends PHPUnit_TestCase {
43+
class Tests_Auth_OpenID_BinLongConvert extends PHPUnit_Framework_TestCase {
4544
var $lib;
4645
var $bin;
4746
var $lng;
4847

49-
function Tests_Auth_OpenID_BinLongConvert(&$lib, $bin, $lng)
48+
function Tests_Auth_OpenID_BinLongConvert($lib, $bin, $lng)
5049
{
5150
$this->lib =& $lib;
5251
$this->bin = $bin;
@@ -62,12 +61,12 @@ function runTest()
6261
}
6362
}
6463

65-
class Tests_Auth_OpenID_Base64ToLong extends PHPUnit_TestCase {
64+
class Tests_Auth_OpenID_Base64ToLong extends PHPUnit_Framework_TestCase {
6665
var $num;
6766
var $b64;
6867
var $lib;
6968

70-
function Tests_Auth_OpenID_Base64ToLong(&$lib, $b64, $num)
69+
function Tests_Auth_OpenID_Base64ToLong($lib, $b64, $num)
7170
{
7271
$this->lib = $lib;
7372
$this->b64 = $b64;
@@ -82,7 +81,7 @@ function runTest()
8281
}
8382

8483
class Tests_Auth_OpenID_LongToBase64 extends Tests_Auth_OpenID_Base64ToLong {
85-
function Tests_Auth_OpenID_LongToBase64(&$lib, $b64, $num)
84+
function Tests_Auth_OpenID_LongToBase64($lib, $b64, $num)
8685
{
8786
$this->lib = $lib;
8887
$this->b64 = $b64;
@@ -96,8 +95,8 @@ function runTest()
9695
}
9796
}
9897

99-
class Tests_Auth_OpenID_Rand extends PHPUnit_TestCase {
100-
function Tests_Auth_OpenID_Rand(&$lib)
98+
class Tests_Auth_OpenID_Rand extends PHPUnit_Framework_TestCase {
99+
function Tests_Auth_OpenID_Rand($lib)
101100
{
102101
$this->lib =& $lib;
103102
}
@@ -141,7 +140,7 @@ function Tests_Auth_OpenID_maxint()
141140
}
142141

143142

144-
class Tests_Auth_OpenID_BigMath extends PHPUnit_TestSuite {
143+
class Tests_Auth_OpenID_BigMath extends PHPUnit_Framework_TestSuite {
145144
function _parseBase64Data()
146145
{
147146
$lines = Tests_Auth_OpenID_readlines('n2b64');
@@ -220,15 +219,16 @@ function _addBinLongTests()
220219
function Tests_Auth_OpenID_BigMath($name)
221220
{
222221
$this->setName($name);
223-
224-
if (!defined('Auth_OpenID_NO_MATH_SUPPORT')) {
225-
$this->addTestSuite('Tests_Auth_OpenID_BigInt');
226-
$this->_addB64Tests();
227-
$this->_addBinLongTests();
228-
$test = new Tests_Auth_OpenID_Rand(Auth_OpenID_getMathLib());
229-
$test->setName('Big number rand');
230-
$this->addTest($test);
222+
223+
if (defined('Auth_OpenID_NO_MATH_SUPPORT')) {
224+
return;
231225
}
226+
227+
$this->_addB64Tests();
228+
$this->_addBinLongTests();
229+
$test = new Tests_Auth_OpenID_Rand(Auth_OpenID_getMathLib());
230+
$test->setName('Big number rand');
231+
$this->addTest($test);
232232
}
233233
}
234234

0 commit comments

Comments
 (0)