1af2cfd7bSChristopher Smith<?php 2af2cfd7bSChristopher Smith/** 3af2cfd7bSChristopher Smith * Unit Test for inc/common.php - pageinfo() 4af2cfd7bSChristopher Smith * 5af2cfd7bSChristopher Smith * @author Christopher Smith <chris@jalakai.co.uk> 6af2cfd7bSChristopher Smith */ 7af2cfd7bSChristopher Smithclass common_pageinfo_test extends DokuWikiTest { 8af2cfd7bSChristopher Smith 9*b12755b0SAndreas Gohr public function setup() : void { 10af2cfd7bSChristopher Smith parent::setup(); 11af2cfd7bSChristopher Smith 12af2cfd7bSChristopher Smith global $USERINFO; 13*b12755b0SAndreas Gohr $USERINFO = [ 14af2cfd7bSChristopher Smith 'pass' => '179ad45c6ce2cb97cf1029e212046e81', 15af2cfd7bSChristopher Smith 'name' => 'Arthur Dent', 16af2cfd7bSChristopher Smith 'mail' => 'arthur@example.com', 17*b12755b0SAndreas Gohr 'grps' => ['admin', 'user'], 18*b12755b0SAndreas Gohr ]; 19af2cfd7bSChristopher Smith $_SERVER['REMOTE_USER'] = 'testuser'; 20af2cfd7bSChristopher Smith $_SERVER['REMOTE_ADDR'] = '1.2.3.4'; 21af2cfd7bSChristopher Smith } 22af2cfd7bSChristopher Smith 23*b12755b0SAndreas Gohr protected function get_expected_pageinfo() { 24af2cfd7bSChristopher Smith global $USERINFO; 25*b12755b0SAndreas Gohr $info = [ 26af2cfd7bSChristopher Smith 'isadmin' => true, 27af2cfd7bSChristopher Smith 'ismanager' => true, 28af2cfd7bSChristopher Smith 'userinfo' => $USERINFO, 29af2cfd7bSChristopher Smith 'perm' => 255, 30af2cfd7bSChristopher Smith 'namespace' => false, 31af2cfd7bSChristopher Smith 'ismobile' => false, 32af2cfd7bSChristopher Smith 'client' => 'testuser', 33*b12755b0SAndreas Gohr ]; 34af2cfd7bSChristopher Smith $info['rev'] = null; 35af2cfd7bSChristopher Smith $info['subscribed'] = false; 36af2cfd7bSChristopher Smith $info['locked'] = false; 37af2cfd7bSChristopher Smith $info['exists'] = false; 38af2cfd7bSChristopher Smith $info['writable'] = true; 39af2cfd7bSChristopher Smith $info['editable'] = true; 40af2cfd7bSChristopher Smith $info['lastmod'] = false; 415d873dd4SAndreas Gohr $info['currentrev'] = false; 42*b12755b0SAndreas Gohr $info['meta'] = []; 43af2cfd7bSChristopher Smith $info['ip'] = null; 44af2cfd7bSChristopher Smith $info['user'] = null; 45af2cfd7bSChristopher Smith $info['sum'] = null; 46af2cfd7bSChristopher Smith $info['editor'] = null; 47af2cfd7bSChristopher Smith 48af2cfd7bSChristopher Smith return $info; 49af2cfd7bSChristopher Smith } 50af2cfd7bSChristopher Smith 51af2cfd7bSChristopher Smith /** 52af2cfd7bSChristopher Smith * check info keys and values for a non-existent page & admin user 53af2cfd7bSChristopher Smith */ 54*b12755b0SAndreas Gohr public function test_basic_nonexistentpage() { 55af2cfd7bSChristopher Smith global $ID,$conf; 56af2cfd7bSChristopher Smith $ID = 'wiki:start'; 57af2cfd7bSChristopher Smith 58*b12755b0SAndreas Gohr $info = $this->get_expected_pageinfo(); 59af2cfd7bSChristopher Smith $info['id'] = 'wiki:start'; 60af2cfd7bSChristopher Smith $info['namespace'] = 'wiki'; 61af2cfd7bSChristopher Smith $info['filepath'] = $conf['datadir'].'/wiki/start.txt'; 62af2cfd7bSChristopher Smith 63af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); 64af2cfd7bSChristopher Smith } 65af2cfd7bSChristopher Smith 66af2cfd7bSChristopher Smith /** 67af2cfd7bSChristopher Smith * check info keys and values for a existing page & admin user 68af2cfd7bSChristopher Smith */ 69*b12755b0SAndreas Gohr public function test_basic_existingpage() { 70af2cfd7bSChristopher Smith global $ID,$conf; 71af2cfd7bSChristopher Smith $ID = 'wiki:syntax'; 72af2cfd7bSChristopher Smith $filename = $conf['datadir'].'/wiki/syntax.txt'; 73af2cfd7bSChristopher Smith $rev = filemtime($filename); 74af2cfd7bSChristopher Smith 75*b12755b0SAndreas Gohr // pageinfo() adds the meta['last_change'] entry on first access; capture the 76*b12755b0SAndreas Gohr // result before reading the expected metadata so it reflects that entry 77*b12755b0SAndreas Gohr $result = pageinfo(); 787866d571SSatoshi Sahara 79*b12755b0SAndreas Gohr $info = $this->get_expected_pageinfo(); 80af2cfd7bSChristopher Smith $info['id'] = 'wiki:syntax'; 81af2cfd7bSChristopher Smith $info['namespace'] = 'wiki'; 82af2cfd7bSChristopher Smith $info['filepath'] = $filename; 83af2cfd7bSChristopher Smith $info['exists'] = true; 84af2cfd7bSChristopher Smith $info['lastmod'] = $rev; 855d873dd4SAndreas Gohr $info['currentrev'] = $rev; 86af2cfd7bSChristopher Smith $info['meta'] = p_get_metadata($ID); 877866d571SSatoshi Sahara // set from revinfo, $pagelog->getRevisionInfo($info['lastmod']) 88*b12755b0SAndreas Gohr $info = array_merge($info, [ 897866d571SSatoshi Sahara 'ip' => '127.0.0.1', 907866d571SSatoshi Sahara 'user' => '', 917866d571SSatoshi Sahara 'sum' => 'created - external edit', 92*b12755b0SAndreas Gohr ]); 937866d571SSatoshi Sahara $info['editor'] = '127.0.0.1'; 94af2cfd7bSChristopher Smith 95*b12755b0SAndreas Gohr $this->assertEquals($info, $result); 96af2cfd7bSChristopher Smith } 97af2cfd7bSChristopher Smith 98af2cfd7bSChristopher Smith /** 99af2cfd7bSChristopher Smith * check info keys and values for anonymous user 100af2cfd7bSChristopher Smith */ 101*b12755b0SAndreas Gohr public function test_anonymoususer() { 102af2cfd7bSChristopher Smith global $ID,$conf,$REV; 103af2cfd7bSChristopher Smith 104af2cfd7bSChristopher Smith unset($_SERVER['REMOTE_USER']); 105*b12755b0SAndreas Gohr global $USERINFO; $USERINFO = []; 106af2cfd7bSChristopher Smith 107af2cfd7bSChristopher Smith $ID = 'wiki:syntax'; 108af2cfd7bSChristopher Smith $filename = $conf['datadir'].'/wiki/syntax.txt'; 109af2cfd7bSChristopher Smith $rev = filemtime($filename); 110af2cfd7bSChristopher Smith 111*b12755b0SAndreas Gohr // pageinfo() adds the meta['last_change'] entry on first access; capture the 112*b12755b0SAndreas Gohr // result before building the expectation so p_get_metadata() sees that entry 113*b12755b0SAndreas Gohr $result = pageinfo(); 114*b12755b0SAndreas Gohr 115*b12755b0SAndreas Gohr $info = $this->get_expected_pageinfo(); 116af2cfd7bSChristopher Smith $info['id'] = 'wiki:syntax'; 117af2cfd7bSChristopher Smith $info['namespace'] = 'wiki'; 118af2cfd7bSChristopher Smith $info['filepath'] = $filename; 119af2cfd7bSChristopher Smith $info['exists'] = true; 120af2cfd7bSChristopher Smith $info['lastmod'] = $rev; 1215d873dd4SAndreas Gohr $info['currentrev'] = $rev; 122af2cfd7bSChristopher Smith $info['meta'] = p_get_metadata($ID); 1237866d571SSatoshi Sahara // set from revinfo, $pagelog->getRevisionInfo($info['lastmod']) 124*b12755b0SAndreas Gohr $info = array_merge($info, [ 1257866d571SSatoshi Sahara 'ip' => '127.0.0.1', 1267866d571SSatoshi Sahara 'user' => '', 1277866d571SSatoshi Sahara 'sum' => 'created - external edit', 128*b12755b0SAndreas Gohr ]); 1297866d571SSatoshi Sahara $info['editor'] = '127.0.0.1'; 130af2cfd7bSChristopher Smith 1317866d571SSatoshi Sahara // anonymous user 132*b12755b0SAndreas Gohr $info = array_merge($info, [ 133af2cfd7bSChristopher Smith 'isadmin' => false, 134af2cfd7bSChristopher Smith 'ismanager' => false, 135af2cfd7bSChristopher Smith 'perm' => 8, 136af2cfd7bSChristopher Smith 'client' => '1.2.3.4', 137*b12755b0SAndreas Gohr ]); 138af2cfd7bSChristopher Smith unset($info['userinfo']); 1397866d571SSatoshi Sahara 140*b12755b0SAndreas Gohr $this->assertEquals($info, $result); 141af2cfd7bSChristopher Smith } 142af2cfd7bSChristopher Smith 143af2cfd7bSChristopher Smith /** 144af2cfd7bSChristopher Smith * check info keys and values with $REV 145af2cfd7bSChristopher Smith * (also see $RANGE tests) 146af2cfd7bSChristopher Smith */ 147*b12755b0SAndreas Gohr public function test_rev() { 148af2cfd7bSChristopher Smith global $ID,$conf,$REV; 149af2cfd7bSChristopher Smith 150af2cfd7bSChristopher Smith $ID = 'wiki:syntax'; 151af2cfd7bSChristopher Smith $filename = $conf['datadir'].'/wiki/syntax.txt'; 152af2cfd7bSChristopher Smith $rev = filemtime($filename); 153af2cfd7bSChristopher Smith $REV = $rev - 100; 154b6cc2b69SGerrit Uitslag $ext = '.txt'; 1557866d571SSatoshi Sahara if ($conf['compression']) { 1567866d571SSatoshi Sahara //compression in $info['filepath'] determined by wikiFN depends also on if the page exist 157b6cc2b69SGerrit Uitslag $ext .= "." . $conf['compression']; //.gz or .bz2 158b6cc2b69SGerrit Uitslag } 159af2cfd7bSChristopher Smith 160*b12755b0SAndreas Gohr $info = $this->get_expected_pageinfo(); 161af2cfd7bSChristopher Smith $info['id'] = 'wiki:syntax'; 162af2cfd7bSChristopher Smith $info['namespace'] = 'wiki'; 163af2cfd7bSChristopher Smith $info['meta'] = p_get_metadata($ID); 164af2cfd7bSChristopher Smith $info['rev'] = $REV; 1655d873dd4SAndreas Gohr $info['currentrev'] = $rev; 166b6cc2b69SGerrit Uitslag $info['filepath'] = str_replace('pages','attic',substr($filename,0,-3).$REV.$ext); 167af2cfd7bSChristopher Smith 168af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); 169af2cfd7bSChristopher Smith $this->assertEquals($rev-100, $REV); 170af2cfd7bSChristopher Smith } 171af2cfd7bSChristopher Smith 172af2cfd7bSChristopher Smith /** 173af2cfd7bSChristopher Smith * check info keys and values with $RANGE 174af2cfd7bSChristopher Smith */ 175*b12755b0SAndreas Gohr public function test_range() { 176af2cfd7bSChristopher Smith global $ID,$conf,$REV,$RANGE; 177af2cfd7bSChristopher Smith 178af2cfd7bSChristopher Smith $ID = 'wiki:syntax'; 179af2cfd7bSChristopher Smith $filename = $conf['datadir'].'/wiki/syntax.txt'; 180af2cfd7bSChristopher Smith $rev = filemtime($filename); 181af2cfd7bSChristopher Smith $range = '1000-2000'; 182af2cfd7bSChristopher Smith 183*b12755b0SAndreas Gohr $info = $this->get_expected_pageinfo(); 184af2cfd7bSChristopher Smith $info['id'] = 'wiki:syntax'; 185af2cfd7bSChristopher Smith $info['namespace'] = 'wiki'; 186af2cfd7bSChristopher Smith $info['exists'] = true; 187af2cfd7bSChristopher Smith $info['lastmod'] = $rev; 1885d873dd4SAndreas Gohr $info['currentrev'] = $rev; 189af2cfd7bSChristopher Smith $info['filepath'] = $filename; 1907866d571SSatoshi Sahara // set from revinfo, $pagelog->getRevisionInfo($info['lastmod']) 191*b12755b0SAndreas Gohr $info = array_merge($info, [ 1927866d571SSatoshi Sahara 'ip' => '127.0.0.1', 1937866d571SSatoshi Sahara 'user' => '', 1947866d571SSatoshi Sahara 'sum' => 'created - external edit', 195*b12755b0SAndreas Gohr ]); 1967866d571SSatoshi Sahara $info['editor'] = '127.0.0.1'; 197af2cfd7bSChristopher Smith 198af2cfd7bSChristopher Smith // check $RANGE without $REV 199af2cfd7bSChristopher Smith // expected result $RANGE unchanged 200af2cfd7bSChristopher Smith $RANGE = $range; 201af2cfd7bSChristopher Smith 202*b12755b0SAndreas Gohr // pageinfo() adds the meta['last_change'] entry on first access; capture the 203*b12755b0SAndreas Gohr // result before reading the expected metadata so it reflects that entry 204*b12755b0SAndreas Gohr $result = pageinfo(); 205*b12755b0SAndreas Gohr $info['meta'] = p_get_metadata($ID); 206*b12755b0SAndreas Gohr 207*b12755b0SAndreas Gohr $this->assertEquals($info, $result); 208af2cfd7bSChristopher Smith $this->assertFalse(isset($REV)); 209af2cfd7bSChristopher Smith $this->assertEquals($range, $RANGE); 210af2cfd7bSChristopher Smith 211af2cfd7bSChristopher Smith // check $RANGE with $REV = current 212af2cfd7bSChristopher Smith // expected result: $RANGE unchanged, $REV cleared 213af2cfd7bSChristopher Smith $REV = $rev; 214af2cfd7bSChristopher Smith $info['rev'] = ''; 215af2cfd7bSChristopher Smith 216af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); 217af2cfd7bSChristopher Smith $this->assertEquals('',$REV); 218af2cfd7bSChristopher Smith $this->assertEquals($range, $RANGE); 219af2cfd7bSChristopher Smith 220af2cfd7bSChristopher Smith // check with a real $REV 221af2cfd7bSChristopher Smith // expected result: $REV and $RANGE are cleared 222af2cfd7bSChristopher Smith $REV = $rev - 100; 223af2cfd7bSChristopher Smith 224af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); 225af2cfd7bSChristopher Smith $this->assertEquals('', $REV); 226af2cfd7bSChristopher Smith $this->assertEquals('', $RANGE); 227af2cfd7bSChristopher Smith } 228af2cfd7bSChristopher Smith 229af2cfd7bSChristopher Smith /** 230af2cfd7bSChristopher Smith * test editor entry and external edit 231af2cfd7bSChristopher Smith */ 232*b12755b0SAndreas Gohr public function test_editor_and_externaledits() { 233af2cfd7bSChristopher Smith global $ID,$conf; 234*b12755b0SAndreas Gohr // use a dedicated page here: this test mutates the changelog and file mtime 235*b12755b0SAndreas Gohr // (adds a changelog entry and touch()es the file), so it must not run against 236*b12755b0SAndreas Gohr // wiki:syntax which the other tests rely on being pristine 237*b12755b0SAndreas Gohr $ID = 'wiki:dokuwiki'; 238*b12755b0SAndreas Gohr $filename = $conf['datadir'].'/wiki/dokuwiki.txt'; 239af2cfd7bSChristopher Smith $rev = filemtime($filename); 240af2cfd7bSChristopher Smith 241*b12755b0SAndreas Gohr $info = $this->get_expected_pageinfo(); 242*b12755b0SAndreas Gohr $info['id'] = 'wiki:dokuwiki'; 243af2cfd7bSChristopher Smith $info['namespace'] = 'wiki'; 244af2cfd7bSChristopher Smith $info['filepath'] = $filename; 245af2cfd7bSChristopher Smith $info['exists'] = true; 246af2cfd7bSChristopher Smith $info['lastmod'] = $rev; 2475d873dd4SAndreas Gohr $info['currentrev'] = $rev; 248*b12755b0SAndreas Gohr $info['meta'] = p_get_metadata($ID); // need $INFO set correctly for updateMetadata() 249af2cfd7bSChristopher Smith 250af2cfd7bSChristopher Smith global $INFO; 251af2cfd7bSChristopher Smith $INFO = $info; 252af2cfd7bSChristopher Smith 253*b12755b0SAndreas Gohr // add an editor for the current version of $ID using the PageFile API 254*b12755b0SAndreas Gohr $pageFile = new \dokuwiki\File\PageFile($ID); 255*b12755b0SAndreas Gohr $logEntry = $pageFile->changelog->addLogEntry([ 256*b12755b0SAndreas Gohr 'date' => $rev, 257*b12755b0SAndreas Gohr 'ip' => $_SERVER['REMOTE_ADDR'], 258*b12755b0SAndreas Gohr 'type' => DOKU_CHANGE_TYPE_EDIT, 259*b12755b0SAndreas Gohr 'id' => $ID, 260*b12755b0SAndreas Gohr 'user' => $_SERVER['REMOTE_USER'], 261*b12755b0SAndreas Gohr 'sum' => '', 262*b12755b0SAndreas Gohr 'extra' => '', 263*b12755b0SAndreas Gohr 'sizechange' => '', 264*b12755b0SAndreas Gohr ]); 265*b12755b0SAndreas Gohr $pageFile->updateMetadata($logEntry); 266af2cfd7bSChristopher Smith 267af2cfd7bSChristopher Smith $info['meta'] = p_get_metadata($ID); 268af2cfd7bSChristopher Smith $info['ip'] = $_SERVER['REMOTE_ADDR']; 2697866d571SSatoshi Sahara $info['user'] = $_SERVER['REMOTE_USER']; 270af2cfd7bSChristopher Smith $info['sum'] = ''; 2717866d571SSatoshi Sahara $info['editor'] = $info['user']; 272af2cfd7bSChristopher Smith 273af2cfd7bSChristopher Smith // with an editor ... 274af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); 275af2cfd7bSChristopher Smith 276af2cfd7bSChristopher Smith // clear the meta['last_change'] value, pageinfo should restore it 277*b12755b0SAndreas Gohr p_set_metadata($ID, ['last_change' => false]); 278af2cfd7bSChristopher Smith 279af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); 280af2cfd7bSChristopher Smith $this->assertEquals($info['meta']['last_change'], p_get_metadata($ID,'last_change')); 281af2cfd7bSChristopher Smith 282af2cfd7bSChristopher Smith // fake an external edit, pageinfo should clear the last change from meta data 283af2cfd7bSChristopher Smith // and not return any editor data 284af2cfd7bSChristopher Smith $now = time() + 10; 285af2cfd7bSChristopher Smith touch($filename, $now); 286af2cfd7bSChristopher Smith 287af2cfd7bSChristopher Smith $info['lastmod'] = $now; 2885d873dd4SAndreas Gohr $info['currentrev'] = $now; 289af2cfd7bSChristopher Smith $info['meta']['last_change'] = false; 290af2cfd7bSChristopher Smith $info['ip'] = null; 291af2cfd7bSChristopher Smith $info['user'] = null; 292af2cfd7bSChristopher Smith $info['sum'] = null; 293af2cfd7bSChristopher Smith $info['editor'] = null; 294af2cfd7bSChristopher Smith 295af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); 296af2cfd7bSChristopher Smith $this->assertEquals($info['meta'], p_get_metadata($ID)); // check metadata has been updated correctly 297af2cfd7bSChristopher Smith } 298af2cfd7bSChristopher Smith 299af2cfd7bSChristopher Smith /** 300af2cfd7bSChristopher Smith * check draft 301af2cfd7bSChristopher Smith */ 302*b12755b0SAndreas Gohr public function test_draft() { 303af2cfd7bSChristopher Smith global $ID,$conf; 304af2cfd7bSChristopher Smith $ID = 'wiki:syntax'; 305af2cfd7bSChristopher Smith $filename = $conf['datadir'].'/wiki/syntax.txt'; 306af2cfd7bSChristopher Smith $rev = filemtime($filename); 307af2cfd7bSChristopher Smith 308*b12755b0SAndreas Gohr $info = $this->get_expected_pageinfo(); 309af2cfd7bSChristopher Smith $info['id'] = 'wiki:syntax'; 310af2cfd7bSChristopher Smith $info['namespace'] = 'wiki'; 311af2cfd7bSChristopher Smith $info['filepath'] = $filename; 312af2cfd7bSChristopher Smith $info['exists'] = true; 313af2cfd7bSChristopher Smith $info['lastmod'] = $rev; 3145d873dd4SAndreas Gohr $info['currentrev'] = $rev; 3157866d571SSatoshi Sahara // set from revinfo, $pagelog->getRevisionInfo($info['lastmod']) 316*b12755b0SAndreas Gohr $info = array_merge($info, [ 3177866d571SSatoshi Sahara 'ip' => '127.0.0.1', 3187866d571SSatoshi Sahara 'user' => '', 319*b12755b0SAndreas Gohr 'sum' => 'created - external edit', 320*b12755b0SAndreas Gohr ]); 3217866d571SSatoshi Sahara $info['editor'] = '127.0.0.1'; 322af2cfd7bSChristopher Smith 323af2cfd7bSChristopher Smith // setup a draft, make it more recent than the current page 324af2cfd7bSChristopher Smith // - pageinfo should recognise it and keep it 325357931f3SGerrit Uitslag 3261ef67323SAndreas Gohr $draft = getCacheName($info['client']."\n".$ID,'.draft'); 327af2cfd7bSChristopher Smith touch($draft, $rev + 10); 328af2cfd7bSChristopher Smith 329af2cfd7bSChristopher Smith $info['draft'] = $draft; 330af2cfd7bSChristopher Smith 331*b12755b0SAndreas Gohr // pageinfo() adds the meta['last_change'] entry on first access; capture the 332*b12755b0SAndreas Gohr // result before reading the expected metadata so it reflects that entry 333*b12755b0SAndreas Gohr $result = pageinfo(); 334*b12755b0SAndreas Gohr $info['meta'] = p_get_metadata($ID); 335*b12755b0SAndreas Gohr 336*b12755b0SAndreas Gohr $this->assertEquals($info, $result); 337af2cfd7bSChristopher Smith $this->assertFileExists($draft); 338af2cfd7bSChristopher Smith 339af2cfd7bSChristopher Smith // make the draft older than the current page 340af2cfd7bSChristopher Smith // - pageinfo should remove it and not return the 'draft' key 341af2cfd7bSChristopher Smith touch($draft,$rev - 10); 342af2cfd7bSChristopher Smith unset($info['draft']); 343af2cfd7bSChristopher Smith 344af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); 345af2cfd7bSChristopher Smith $this->assertFalse(file_exists($draft)); 346af2cfd7bSChristopher Smith } 347af2cfd7bSChristopher Smith 348af2cfd7bSChristopher Smith /** 349af2cfd7bSChristopher Smith * check ismobile 350af2cfd7bSChristopher Smith */ 351*b12755b0SAndreas Gohr public function test_ismobile() { 352af2cfd7bSChristopher Smith global $ID,$conf; 353af2cfd7bSChristopher Smith $ID = 'wiki:start'; 354af2cfd7bSChristopher Smith 355*b12755b0SAndreas Gohr $info = $this->get_expected_pageinfo(); 356af2cfd7bSChristopher Smith $info['id'] = 'wiki:start'; 357af2cfd7bSChristopher Smith $info['namespace'] = 'wiki'; 358af2cfd7bSChristopher Smith $info['filepath'] = $conf['datadir'].'/wiki/start.txt'; 359af2cfd7bSChristopher Smith 360af2cfd7bSChristopher Smith // overkill, ripped from clientismobile() as we aren't testing detection - but forcing it 361af2cfd7bSChristopher Smith $_SERVER['HTTP_X_WAP_PROFILE'] = 'a fake url'; 362af2cfd7bSChristopher Smith $_SERVER['HTTP_ACCEPT'] .= ';wap'; 363af2cfd7bSChristopher Smith $_SERVER['HTTP_USER_AGENT'] = 'blackberry,symbian,hand,mobi,phone'; 364af2cfd7bSChristopher Smith 365af2cfd7bSChristopher Smith $info['ismobile'] = clientismobile(); 366af2cfd7bSChristopher Smith 367af2cfd7bSChristopher Smith $this->assertTrue(clientismobile()); // ensure THIS test fails if clientismobile() returns false 368af2cfd7bSChristopher Smith $this->assertEquals($info, pageinfo()); // it would be a test failure not a pageinfo failure. 369af2cfd7bSChristopher Smith } 370af2cfd7bSChristopher Smith} 371