class SemiMockedFetchText extends FetchText {
/**
- * @var String|null Text to pass as stdin
+ * @var string|null Text to pass as stdin
*/
private $mockStdinText = null;
private $mockSetUp = false;
/**
- * @var Array Invocation counters for the mocked aspects
+ * @var array Invocation counters for the mocked aspects
*/
private $mockInvocations = array( 'getStdin' => 0 );
/**
* Data for the fake stdin
*
- * @param $stdin String The string to be used instead of stdin
+ * @param string $stdin The string to be used instead of stdin
*/
function mockStdin( $stdin ) {
$this->mockStdinText = $stdin;
/**
* Gets invocation counters for mocked methods.
*
- * @return Array An array, whose keys are function names. The corresponding values
+ * @return array An array, whose keys are function names. The corresponding values
* denote the number of times the function has been invoked.
*/
function mockGetInvocations() {
private $exceptionFromAddDBData;
/**
- * @var FetchText the (mocked) FetchText that is to test
+ * @var FetchText The (mocked) FetchText that is to test
*/
private $fetchText;
/**
* Adds a revision to a page, while returning the resuting text's id
*
- * @param $page WikiPage The page to add the revision to
- * @param $text String The revisions text
- * @param $text String The revisions summare
+ * @param WikiPage $page The page to add the revision to
+ * @param string $text The revisions text
+ * @param string $text The revisions summare
*
- * @throws MWExcepion
+ * @throws MWException
*/
private function addRevision( $page, $text, $summary ) {
- $status = $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), $summary );
+ $status = $page->doEditContent(
+ ContentHandler::makeContent( $text, $page->getTitle() ),
+ $summary
+ );
+
if ( $status->isGood() ) {
$value = $status->getValue();
$revision = $value['revision'];
$id = $revision->getTextId();
+
if ( $id > 0 ) {
return $id;
}
}
+
throw new MWException( "Could not determine text id" );
}
try {
$title = Title::newFromText( 'FetchTextTestPage1', $wikitextNamespace );
$page = WikiPage::factory( $title );
- $this->textId1 = $this->addRevision( $page, "FetchTextTestPage1Text1", "FetchTextTestPage1Summary1" );
+ $this->textId1 = $this->addRevision(
+ $page,
+ "FetchTextTestPage1Text1",
+ "FetchTextTestPage1Summary1"
+ );
$title = Title::newFromText( 'FetchTextTestPage2', $wikitextNamespace );
$page = WikiPage::factory( $title );
- $this->textId2 = $this->addRevision( $page, "FetchTextTestPage2Text1", "FetchTextTestPage2Summary1" );
- $this->textId3 = $this->addRevision( $page, "FetchTextTestPage2Text2", "FetchTextTestPage2Summary2" );
- $this->textId4 = $this->addRevision( $page, "FetchTextTestPage2Text3", "FetchTextTestPage2Summary3" );
- $this->textId5 = $this->addRevision( $page, "FetchTextTestPage2Text4 some additional Text ", "FetchTextTestPage2Summary4 extra " );
+ $this->textId2 = $this->addRevision(
+ $page,
+ "FetchTextTestPage2Text1",
+ "FetchTextTestPage2Summary1"
+ );
+ $this->textId3 = $this->addRevision(
+ $page,
+ "FetchTextTestPage2Text2",
+ "FetchTextTestPage2Summary2"
+ );
+ $this->textId4 = $this->addRevision(
+ $page,
+ "FetchTextTestPage2Text3",
+ "FetchTextTestPage2Summary3"
+ );
+ $this->textId5 = $this->addRevision(
+ $page,
+ "FetchTextTestPage2Text4 some additional Text ",
+ "FetchTextTestPage2Summary4 extra "
+ );
} catch ( Exception $e ) {
// We'd love to pass $e directly. However, ... see
// documentation of exceptionFromAddDBData
/**
* Helper to relate FetchText's input and output
+ * @param string $input
+ * @param string $expectedOutput
*/
private function assertFilter( $input, $expectedOutput ) {
$this->fetchText->mockStdin( $input );