From 9f48e9e96542e34c508642b47a556ff5806b7412 Mon Sep 17 00:00:00 2001 From: Platonides Date: Wed, 29 Sep 2010 15:22:47 +0000 Subject: [PATCH] Fight PHP Fatal error: Call to a member function attributes() on a non-object --- maintenance/tests/phpunit/includes/api/ApiTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/maintenance/tests/phpunit/includes/api/ApiTest.php b/maintenance/tests/phpunit/includes/api/ApiTest.php index 7eab2d748c..ee77c86985 100644 --- a/maintenance/tests/phpunit/includes/api/ApiTest.php +++ b/maintenance/tests/phpunit/includes/api/ApiTest.php @@ -141,6 +141,7 @@ class ApiTest extends ApiTestSetup { $sxe = simplexml_load_string( $req->getContent() ); $this->assertNotType( "bool", $sxe ); $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) ); + $this->assertNotType( "null", $sxe->login[0] ); $a = $sxe->login[0]->attributes()->result[0]; $this->assertEquals( ' result="NeedToken"', $a->asXML() ); @@ -179,6 +180,7 @@ class ApiTest extends ApiTestSetup { $sxe = simplexml_load_string( $req->getContent() ); $this->assertNotType( "bool", $sxe ); $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) ); + $this->assertNotType( "null", $sxe->login[0] ); $a = $sxe->login[0]->attributes()->result[0]; $this->assertEquals( ' result="NeedToken"', $a->asXML() ); @@ -191,8 +193,9 @@ class ApiTest extends ApiTestSetup { $req->execute(); $cj = $req->getCookieJar(); - $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/', - $cj->serializeToHttpRequest( $wgScriptPath, $wgServerName ) ); + $serializedCookie = $cj->serializeToHttpRequest( $wgScriptPath, $wgServerName ); + $this->assertNotEquals( '', $serializedCookie ); + $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/', $serializedCookie ); return $cj; -- 2.20.1