+ /**
+ * Assumes that only getSubjectPage and getTalkPage will ever be called, and everything passed
+ * to them will have namespace 0.
+ */
+ private function getMockNsInfo() : NamespaceInfo {
+ $mock = $this->createMock( NamespaceInfo::class );
+ $mock->method( 'getSubjectPage' )->will( $this->returnArgument( 0 ) );
+ $mock->method( 'getTalkPage' )->will( $this->returnCallback(
+ function ( $target ) {
+ return new TitleValue( 1, $target->getDbKey() );
+ }
+ ) );
+ $mock->expects( $this->never() )
+ ->method( $this->anythingBut( 'getSubjectPage', 'getTalkPage' ) );
+ return $mock;
+ }
+
+ /**
+ * No methods may be called except provided callbacks, if any.
+ *
+ * @param array $callbacks Keys are method names, values are callbacks
+ * @param array $counts Keys are method names, values are expected number of times to be called
+ * (default is any number is okay)
+ */
+ private function getMockRevisionLookup(
+ array $callbacks = [], array $counts = []
+ ) : RevisionLookup {
+ $mock = $this->createMock( RevisionLookup::class );
+ foreach ( $callbacks as $method => $callback ) {
+ $count = isset( $counts[$method] ) ? $this->exactly( $counts[$method] ) : $this->any();
+ $mock->expects( $count )
+ ->method( $method )
+ ->will( $this->returnCallback( $callbacks[$method] ) );
+ }
+ $mock->expects( $this->never() )
+ ->method( $this->anythingBut( ...array_keys( $callbacks ) ) );
+ return $mock;
+ }
+