<?php
-require_once( 'PHPUnit.php' );
-require_once( '../includes/Defines.php' );
-require_once( '../includes/Profiling.php' );
-require_once( '../includes/GlobalFunctions.php' );
-
-class GlobalTest extends PHPUnit_TestCase {
- function GlobalTest( $name ) {
- $this->PHPUnit_TestCase( $name );
- }
-
- function setUp() {
- $this->save = array();
- $saveVars = array( 'wgReadOnlyFile' );
- foreach( $saveVars as $var ) {
- if( isset( $GLOBALS[$var] ) ) {
- $this->save[$var] = $GLOBALS[$var];
- }
- }
- $GLOBALS['wgReadOnlyFile'] = wfTempDir() . '/testReadOnly-' . mt_rand();
- }
-
- function tearDown() {
- foreach( $this->save as $var => $data ) {
- $GLOBALS[$var] = $data;
- }
- }
-
+class GlobalTest extends PHPUnit_Framework_TestCase {
function testRandom() {
# This could hypothetically fail, but it shouldn't ;)
$this->assertFalse(
wfTimestamp( TS_DB, '2001-01-15 12:34:56' ),
'TS_DB to TS_DB' );
}
+
+ function testBasename() {
+ $sets = array(
+ '' => '',
+ '/' => '',
+ '\\' => '',
+ '//' => '',
+ '\\\\' => '',
+ 'a' => 'a',
+ 'aaaa' => 'aaaa',
+ '/a' => 'a',
+ '\\a' => 'a',
+ '/aaaa' => 'aaaa',
+ '\\aaaa' => 'aaaa',
+ '/aaaa/' => 'aaaa',
+ '\\aaaa\\' => 'aaaa',
+ '\\aaaa\\' => 'aaaa',
+ '/mnt/upload3/wikipedia/en/thumb/8/8b/Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg' => '93px-Zork_Grand_Inquisitor_box_cover.jpg',
+ 'C:\\Progra~1\\Wikime~1\\Wikipe~1\\VIEWER.EXE' => 'VIEWER.EXE',
+ 'Östergötland_coat_of_arms.png' => 'Östergötland_coat_of_arms.png',
+ );
+ foreach( $sets as $from => $to ) {
+ $this->assertEquals( $to, wfBaseName( $from ),
+ "wfBaseName('$from') => '$to'");
+ }
+ }
/* TODO: many more! */
}
-?>
\ No newline at end of file
+?>