17ae29fa4SChristopher Smith<?php 27ae29fa4SChristopher Smith 37ae29fa4SChristopher Smithclass common_infofunctions_test extends DokuWikiTest { 47ae29fa4SChristopher Smith 5*1c33cec3SAndreas Gohr function setup() : void { 67ae29fa4SChristopher Smith parent::setup(); 77ae29fa4SChristopher Smith 87ae29fa4SChristopher Smith global $USERINFO; 97ae29fa4SChristopher Smith $USERINFO = array( 107ae29fa4SChristopher Smith 'pass' => '179ad45c6ce2cb97cf1029e212046e81', 117ae29fa4SChristopher Smith 'name' => 'Arthur Dent', 127ae29fa4SChristopher Smith 'mail' => '[email protected]', 137ae29fa4SChristopher Smith 'grps' => array ('admin','user'), 147ae29fa4SChristopher Smith ); 157ae29fa4SChristopher Smith $_SERVER['REMOTE_USER'] = 'testuser'; 167ae29fa4SChristopher Smith $_SERVER['REMOTE_ADDR'] = '1.2.3.4'; 177ae29fa4SChristopher Smith } 187ae29fa4SChristopher Smith 197ae29fa4SChristopher Smith function _get_info() { 207ae29fa4SChristopher Smith global $USERINFO; 217ae29fa4SChristopher Smith $info = array ( 227ae29fa4SChristopher Smith 'isadmin' => true, 237ae29fa4SChristopher Smith 'ismanager' => true, 247ae29fa4SChristopher Smith 'userinfo' => $USERINFO, 257ae29fa4SChristopher Smith 'perm' => 255, 267ae29fa4SChristopher Smith 'namespace' => false, 277ae29fa4SChristopher Smith 'ismobile' => false, 287ae29fa4SChristopher Smith 'client' => 'testuser', 297ae29fa4SChristopher Smith ); 307ae29fa4SChristopher Smith 317ae29fa4SChristopher Smith return $info; 327ae29fa4SChristopher Smith } 337ae29fa4SChristopher Smith 347ae29fa4SChristopher Smith /** 357ae29fa4SChristopher Smith * Its important to have the correct set of keys. 367ae29fa4SChristopher Smith * Other functions provide the values 377ae29fa4SChristopher Smith */ 387ae29fa4SChristopher Smith function test_basicinfo(){ 3968491db9SPhy global $ID; 407ae29fa4SChristopher Smith // test with REMOTE_USER set and the user an admin user 417ae29fa4SChristopher Smith $info = $this->_get_info(); 427ae29fa4SChristopher Smith $this->assertEquals(basicinfo($ID,true),$info); 437ae29fa4SChristopher Smith 447ae29fa4SChristopher Smith // with $httpclient parameter set to false 457ae29fa4SChristopher Smith unset($info['ismobile']); 467ae29fa4SChristopher Smith $this->assertEquals(basicinfo($ID,false),$info); 477ae29fa4SChristopher Smith 487ae29fa4SChristopher Smith // with anonymous user 497ae29fa4SChristopher Smith unset($_SERVER['REMOTE_USER']); 507ae29fa4SChristopher Smith global $USERINFO; $USERINFO = array(); 517ae29fa4SChristopher Smith 527ae29fa4SChristopher Smith $info = array( 537ae29fa4SChristopher Smith 'isadmin' => false, 547ae29fa4SChristopher Smith 'ismanager' => false, 557ae29fa4SChristopher Smith 'perm' => 8, 567ae29fa4SChristopher Smith 'namespace' => false, 577ae29fa4SChristopher Smith 'ismobile' => false, 587ae29fa4SChristopher Smith 'client' => '1.2.3.4', 597ae29fa4SChristopher Smith ); 607ae29fa4SChristopher Smith $this->assertEquals(basicinfo($ID,true),$info); 617ae29fa4SChristopher Smith } 627ae29fa4SChristopher Smith 637ae29fa4SChristopher Smith} 647ae29fa4SChristopher Smith 657ae29fa4SChristopher Smith//Setup VIM: ex: et ts=4 : 66