Last modified: 2012-03-08 19:06:18 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 15966 - Provide a way to invoke the Parser from within a PHPUnit test
Provide a way to invoke the Parser from within a PHPUnit test
Status: RESOLVED WORKSFORME
Product: MediaWiki
Classification: Unclassified
Unit tests (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-10-13 15:52 UTC by sharon.dagan
Modified: 2012-03-08 19:06 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description sharon.dagan 2008-10-13 15:52:02 UTC
For the sake of unit testing of extensions code, please provide an *easy* way to invoke the Parser from within a PHPUnit test. 

For example:

/*
 *  returns a ready-to-use Parser
 */
class ParserMock {
  var $parser;
 
  function __constructor() {
     $conf   = new Array( ... );
     $parser = new Parser( $conf );
     ...
  }
 
  function setHook( ... ) {
    ...
    $parser->setHook( ... );
  }  

  function parse( $text ) {
     $title = new Title( 'test' );
     $opt = new ParserOptions( ... );
     returns $parser->parse( $text, $title, $opt );
  } 
}

class MyFooTagTest extends PHPUnit_Framework_TestCase {
  var $parserMock;
  
  function setUp() {
    $parserMock = new ParserMock;
    $myFooTag   = new MyFooTag
    $parserMock->setHook( 'foo', array( & $myFooTag, 'foo' ) );
  }

  function testFoo() {
    $out = $parserMock->parse( '<foo f="F">Bar</foo>' );
    ...
  }
}
Comment 1 Tim Starling 2008-10-16 04:24:24 UTC
That's basically how it is already, except you can use the actual Parser class instead of "ParserMock". Have you encountered some problem with this approach?
Comment 2 Antoine "hashar" Musso (WMF) 2012-01-30 17:43:14 UTC
resetting to wikibugs-l@lists.wikimedia.org assignee.
Comment 3 Max Semenik 2012-03-08 19:06:18 UTC
It works this way already. Unless there was something specific requested here, it's WORKSFORME.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links