19 list( $dbMock, $backendMock, $wrapperMock ) = $mocks;
21 $dbMock->expects( $dbReadsExpected )
22 ->method(
'selectField' )
23 ->will( $this->returnValue( $dbReturnValue ) );
25 $newPaths = $wrapperMock->getBackendPaths( [ $originalPath ], $latest );
35 $mocksForCaching = $this->
getMocks();
42 '96246614d75ba1703bdfd5d7660bb57407aaf5d9',
43 $prefix .
'-public/f/o/foobar.jpg',
44 $prefix .
'-original/9/6/2/96246614d75ba1703bdfd5d7660bb57407aaf5d9',
45 'Public path translated correctly',
51 '96246614d75ba1703bdfd5d7660bb57407aaf5d9',
52 $prefix .
'-public/f/o/foobar.jpg',
53 $prefix .
'-original/9/6/2/96246614d75ba1703bdfd5d7660bb57407aaf5d9',
54 'LRU cache leveraged',
60 '96246614d75ba1703bdfd5d7660bb57407aaf5d9',
61 $prefix .
'-public/f/o/foobar.jpg',
62 $prefix .
'-original/9/6/2/96246614d75ba1703bdfd5d7660bb57407aaf5d9',
69 '96246614d75ba1703bdfd5d7660bb57407aaf5d9',
70 $prefix .
'-deleted/f/o/foobar.jpg',
71 $prefix .
'-original/f/o/o/foobar',
72 'Deleted path translated correctly',
79 $prefix .
'-public/b/a/baz.jpg',
80 $prefix .
'-public/b/a/baz.jpg',
81 'Path left untouched if no sha1 can be found',
90 list( $dbMock, $backendMock, $wrapperMock ) = $this->
getMocks();
92 $sha1Path =
'mwstore://' . $this->backendName .
'/' . $this->repoName
93 .
'-original/9/6/2/96246614d75ba1703bdfd5d7660bb57407aaf5d9';
94 $filenamePath =
'mwstore://' . $this->backendName .
'/' . $this->repoName
95 .
'-public/f/o/foobar.jpg';
97 $dbMock->expects( $this->once() )
98 ->method(
'selectField' )
99 ->will( $this->returnValue(
'96246614d75ba1703bdfd5d7660bb57407aaf5d9' ) );
101 $backendMock->expects( $this->once() )
102 ->method(
'getFileContentsMulti' )
103 ->will( $this->returnValue( [ $sha1Path =>
'foo' ] ) );
105 $result = $wrapperMock->getFileContentsMulti( [
'srcs' => [ $filenamePath ] ] );
108 [ $filenamePath =>
'foo' ],
110 'File contents paths translated properly'
115 $dbMock = $this->getMockBuilder( Wikimedia\Rdbms\DatabaseMysqli::class )
116 ->disableOriginalClone()
117 ->disableOriginalConstructor()
120 $backendMock = $this->getMockBuilder( FSFileBackend::class )
121 ->setConstructorArgs( [ [
122 'name' => $this->backendName,
127 $wrapperMock = $this->getMockBuilder( FileBackendDBRepoWrapper::class )
128 ->setMethods( [
'getDB' ] )
129 ->setConstructorArgs( [ [
130 'backend' => $backendMock,
131 'repoName' => $this->repoName,
132 'dbHandleFactory' =>
null
136 $wrapperMock->expects( $this->
any() )->method(
'getDB' )->will( $this->returnValue( $dbMock ) );
138 return [ $dbMock, $backendMock, $wrapperMock ];
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
testGetBackendPaths( $mocks, $latest, $dbReadsExpected, $dbReturnValue, $originalPath, $expectedBackendPath, $message)
getBackendPathsProvider FileBackendDBRepoWrapper::getBackendPaths
getBackendPathsProvider()
testGetFileContentsMulti()
FileBackendDBRepoWrapper::getFileContentsMulti.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list