Tests: Make phpunit providers "public static".
[lhc/web/wiklou.git] / tests / phpunit / includes / filebackend / FileBackendTest.php
index a08910a..cacaaa3 100644 (file)
@@ -88,7 +88,7 @@ class FileBackendTest extends MediaWikiTestCase {
                        "FileBackend::isStoragePath on path '$path'" );
        }
 
-       function provider_testIsStoragePath() {
+       public static function provider_testIsStoragePath() {
                return array(
                        array( 'mwstore://', true ),
                        array( 'mwstore://backend', true ),
@@ -112,7 +112,7 @@ class FileBackendTest extends MediaWikiTestCase {
                        "FileBackend::splitStoragePath on path '$path'" );
        }
 
-       function provider_testSplitStoragePath() {
+       public static function provider_testSplitStoragePath() {
                return array(
                        array( 'mwstore://backend/container', array( 'backend', 'container', '' ) ),
                        array( 'mwstore://backend/container/', array( 'backend', 'container', '' ) ),
@@ -136,7 +136,7 @@ class FileBackendTest extends MediaWikiTestCase {
                        "FileBackend::normalizeStoragePath on path '$path'" );
        }
 
-       function provider_normalizeStoragePath() {
+       public static function provider_normalizeStoragePath() {
                return array(
                        array( 'mwstore://backend/container', 'mwstore://backend/container' ),
                        array( 'mwstore://backend/container/', 'mwstore://backend/container' ),
@@ -162,7 +162,7 @@ class FileBackendTest extends MediaWikiTestCase {
                        "FileBackend::parentStoragePath on path '$path'" );
        }
 
-       function provider_testParentStoragePath() {
+       public static function provider_testParentStoragePath() {
                return array(
                        array( 'mwstore://backend/container/path/to/obj', 'mwstore://backend/container/path/to' ),
                        array( 'mwstore://backend/container/path/to', 'mwstore://backend/container/path' ),
@@ -387,6 +387,14 @@ class FileBackendTest extends MediaWikiTestCase {
                        $dest, // dest
                );
 
+               $op2 = $op;
+               $op2['ignoreMissingSource'] = true;
+               $cases[] = array(
+                       $op2, // operation
+                       self::baseStorePath() . '/unittest-cont-bad/e/file.txt', // source
+                       $dest, // dest
+               );
+
                return $cases;
        }
 
@@ -499,6 +507,14 @@ class FileBackendTest extends MediaWikiTestCase {
                        $dest, // dest
                );
 
+               $op2 = $op;
+               $op2['ignoreMissingSource'] = true;
+               $cases[] = array(
+                       $op2, // operation
+                       self::baseStorePath() . '/unittest-cont-bad/e/file.txt', // source
+                       $dest, // dest
+               );
+
                return $cases;
        }
 
@@ -582,6 +598,14 @@ class FileBackendTest extends MediaWikiTestCase {
                        true // succeeds
                );
 
+               $op['ignoreMissingSource'] = true;
+               $op['src'] = self::baseStorePath() . '/unittest-cont-bad/e/file.txt';
+               $cases[] = array(
+                       $op, // operation
+                       false, // without source
+                       true // succeeds
+               );
+
                return $cases;
        }
 
@@ -903,7 +927,7 @@ class FileBackendTest extends MediaWikiTestCase {
                }
        }
 
-       function provider_testConcatenate() {
+       public static function provider_testConcatenate() {
                $cases = array();
 
                $rand = mt_rand( 0, 2000000000 ) . time();
@@ -1017,7 +1041,7 @@ class FileBackendTest extends MediaWikiTestCase {
                }
        }
 
-       function provider_testGetFileStat() {
+       public static function provider_testGetFileStat() {
                $cases = array();
 
                $base = self::baseStorePath();
@@ -1072,7 +1096,7 @@ class FileBackendTest extends MediaWikiTestCase {
                }
        }
 
-       function provider_testGetFileContents() {
+       public static function provider_testGetFileContents() {
                $cases = array();
 
                $base = self::baseStorePath();
@@ -1140,7 +1164,7 @@ class FileBackendTest extends MediaWikiTestCase {
                $tmpFile->bind( $obj );
        }
 
-       function provider_testGetLocalCopy() {
+       public static function provider_testGetLocalCopy() {
                $cases = array();
 
                $base = self::baseStorePath();
@@ -1206,7 +1230,7 @@ class FileBackendTest extends MediaWikiTestCase {
                }
        }
 
-       function provider_testGetLocalReference() {
+       public static function provider_testGetLocalReference() {
                $cases = array();
 
                $base = self::baseStorePath();
@@ -1281,7 +1305,7 @@ class FileBackendTest extends MediaWikiTestCase {
                }
        }
 
-       function provider_testGetFileHttpUrl() {
+       public static function provider_testGetFileHttpUrl() {
                $cases = array();
 
                $base = self::baseStorePath();
@@ -1305,7 +1329,7 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->tearDownFiles();
        }
 
-       function provider_testPrepareAndClean() {
+       public static function provider_testPrepareAndClean() {
                $base = self::baseStorePath();
                return array(
                        array( "$base/unittest-cont1/e/a/z/some_file1.txt", true ),
@@ -2024,53 +2048,79 @@ class FileBackendTest extends MediaWikiTestCase {
        private function doTestLockCalls() {
                $backendName = $this->backendClass();
 
-               for ( $i=0; $i<50; $i++ ) {
-                       $paths = array(
-                               "test1.txt",
-                               "test2.txt",
-                               "test3.txt",
-                               "subdir1",
-                               "subdir1", // duplicate
-                               "subdir1/test1.txt",
-                               "subdir1/test2.txt",
-                               "subdir2",
-                               "subdir2", // duplicate
-                               "subdir2/test3.txt",
-                               "subdir2/test4.txt",
-                               "subdir2/subdir",
-                               "subdir2/subdir/test1.txt",
-                               "subdir2/subdir/test2.txt",
-                               "subdir2/subdir/test3.txt",
-                               "subdir2/subdir/test4.txt",
-                               "subdir2/subdir/test5.txt",
-                               "subdir2/subdir/sub",
-                               "subdir2/subdir/sub/test0.txt",
-                               "subdir2/subdir/sub/120-px-file.txt",
-                       );
+               $paths = array(
+                       "test1.txt",
+                       "test2.txt",
+                       "test3.txt",
+                       "subdir1",
+                       "subdir1", // duplicate
+                       "subdir1/test1.txt",
+                       "subdir1/test2.txt",
+                       "subdir2",
+                       "subdir2", // duplicate
+                       "subdir2/test3.txt",
+                       "subdir2/test4.txt",
+                       "subdir2/subdir",
+                       "subdir2/subdir/test1.txt",
+                       "subdir2/subdir/test2.txt",
+                       "subdir2/subdir/test3.txt",
+                       "subdir2/subdir/test4.txt",
+                       "subdir2/subdir/test5.txt",
+                       "subdir2/subdir/sub",
+                       "subdir2/subdir/sub/test0.txt",
+                       "subdir2/subdir/sub/120-px-file.txt",
+               );
 
+               for ( $i=0; $i<25; $i++ ) {
                        $status = $this->backend->lockFiles( $paths, LockManager::LOCK_EX );
-                       $this->assertEquals( array(), $status->errors,
-                               "Locking of files succeeded ($backendName)." );
+                       $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+                               "Locking of files succeeded ($backendName) ($i)." );
                        $this->assertEquals( true, $status->isOK(),
-                               "Locking of files succeeded with OK status ($backendName)." );
+                               "Locking of files succeeded with OK status ($backendName) ($i)." );
 
                        $status = $this->backend->lockFiles( $paths, LockManager::LOCK_SH );
-                       $this->assertEquals( array(), $status->errors,
-                               "Locking of files succeeded ($backendName)." );
+                       $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+                               "Locking of files succeeded ($backendName) ($i)." );
                        $this->assertEquals( true, $status->isOK(),
-                               "Locking of files succeeded with OK status ($backendName)." );
+                               "Locking of files succeeded with OK status ($backendName) ($i)." );
 
                        $status = $this->backend->unlockFiles( $paths, LockManager::LOCK_SH );
-                       $this->assertEquals( array(), $status->errors,
-                               "Locking of files succeeded ($backendName)." );
+                       $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+                               "Locking of files succeeded ($backendName) ($i)." );
+                       $this->assertEquals( true, $status->isOK(),
+                               "Locking of files succeeded with OK status ($backendName) ($i)." );
+
+                       $status = $this->backend->unlockFiles( $paths, LockManager::LOCK_EX );
+                       $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+                               "Locking of files succeeded ($backendName). ($i)" );
                        $this->assertEquals( true, $status->isOK(),
-                               "Locking of files succeeded with OK status ($backendName)." );
+                               "Locking of files succeeded with OK status ($backendName) ($i)." );
+
+                       ## Flip the acquire/release ordering around ##
+
+                       $status = $this->backend->lockFiles( $paths, LockManager::LOCK_SH );
+                       $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+                               "Locking of files succeeded ($backendName) ($i)." );
+                       $this->assertEquals( true, $status->isOK(),
+                               "Locking of files succeeded with OK status ($backendName) ($i)." );
+
+                       $status = $this->backend->lockFiles( $paths, LockManager::LOCK_EX );
+                       $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+                               "Locking of files succeeded ($backendName) ($i)." );
+                       $this->assertEquals( true, $status->isOK(),
+                               "Locking of files succeeded with OK status ($backendName) ($i)." );
 
                        $status = $this->backend->unlockFiles( $paths, LockManager::LOCK_EX );
-                       $this->assertEquals( array(), $status->errors,
-                               "Locking of files succeeded ($backendName)." );
+                       $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+                               "Locking of files succeeded ($backendName). ($i)" );
+                       $this->assertEquals( true, $status->isOK(),
+                               "Locking of files succeeded with OK status ($backendName) ($i)." );
+
+                       $status = $this->backend->unlockFiles( $paths, LockManager::LOCK_SH );
+                       $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+                               "Locking of files succeeded ($backendName) ($i)." );
                        $this->assertEquals( true, $status->isOK(),
-                               "Locking of files succeeded with OK status ($backendName)." );
+                               "Locking of files succeeded with OK status ($backendName) ($i)." );
                }
 
                $status = Status::newGood();