18 # Forge a FileRepo object to not have to rely on local wiki settings
20 if ( $this->
getCliArg(
'use-filebackend' ) ) {
24 if ( $conf[
'name'] ==
$name ) {
29 unset( $useConfig[
'fileJournal'] );
30 $useConfig[
'name'] =
'local-testing';
31 $class = $useConfig[
'class'];
32 $backend =
new $class( $useConfig );
35 'name' =>
'local-testing',
38 'unittests-public' =>
"{$tmpPrefix}/public",
39 'unittests-thumb' =>
"{$tmpPrefix}/thumb",
40 'unittests-temp' =>
"{$tmpPrefix}/temp",
41 'unittests-deleted' =>
"{$tmpPrefix}/deleted",
46 'name' =>
'unittests',
50 $this->date = gmdate(
"YmdHis" );
51 $this->createdFiles = [];
56 $this->repo->cleanupBatch( $this->createdFiles );
68 private function storeit( $originalName, $srcPath, $flags ) {
69 $hashPath = $this->repo->getHashPath( $originalName );
70 $dstRel =
"$hashPath{$this->date}!$originalName";
71 $dstUrlRel = $hashPath . $this->date .
'!' . rawurlencode( $originalName );
73 $result = $this->repo->store( $srcPath,
'temp', $dstRel, $flags );
74 $result->value = $this->repo->getVirtualUrl(
'temp' ) .
'/' . $dstUrlRel;
75 $this->createdFiles[] =
$result->value;
88 private function storecohort( $fn, $infn, $otherfn, $fromrepo ) {
89 $f = $this->
storeit( $fn, $infn, 0 );
90 $this->assertTrue( $f->isOK(),
'failed to store a new file' );
91 $this->assertEquals( $f->failCount, 0,
"counts wrong {$f->successCount} {$f->failCount}" );
92 $this->assertEquals( $f->successCount, 1,
"counts wrong {$f->successCount} {$f->failCount}" );
99 $this->assertTrue( $f->isOK(),
'We should be allowed to overwrite' );
100 $this->assertEquals( $f->failCount, 0,
"counts wrong {$f->successCount} {$f->failCount}" );
101 $this->assertEquals( $f->successCount, 1,
"counts wrong {$f->successCount} {$f->failCount}" );
103 $f = $this->
storeit( $fn, $infn, 0 );
104 $this->assertFalse( $f->isOK(),
'We should not be allowed to overwrite' );
105 $this->assertEquals( $f->failCount, 1,
"counts wrong {$f->successCount} {$f->failCount}" );
106 $this->assertEquals( $f->successCount, 0,
"counts wrong {$f->successCount} {$f->failCount}" );
109 $this->assertTrue( $f->isOK(),
'We should be able to overwrite the same content' );
110 $this->assertEquals( $f->failCount, 0,
"counts wrong {$f->successCount} {$f->failCount}" );
111 $this->assertEquals( $f->successCount, 1,
"counts wrong {$f->successCount} {$f->failCount}" );
115 $otherfn = $f->value;
118 $this->assertFalse( $f->isOK(),
'We should not be allowed to overwrite different content' );
119 $this->assertEquals( $f->failCount, 1,
"counts wrong {$f->successCount} {$f->failCount}" );
120 $this->assertEquals( $f->successCount, 0,
"counts wrong {$f->successCount} {$f->failCount}" );
130 "$IP/tests/phpunit/data/filerepo/wiki.png",
131 "$IP/tests/phpunit/data/filerepo/video.png",
136 "$IP/tests/phpunit/data/filerepo/wiki.png",
137 "$IP/tests/phpunit/data/filerepo/video.png",