ParserIntegrationTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. use Wikimedia\ScopedCallback;
  3. /**
  4. * This is the TestCase subclass for running a single parser test via the
  5. * ParserTestRunner integration test system.
  6. *
  7. * Note: the following groups are not used by PHPUnit.
  8. * The list in ParserTestFileSuite::__construct() is used instead.
  9. *
  10. * @group large
  11. * @group Database
  12. * @group Parser
  13. * @group ParserTests
  14. *
  15. * @covers Parser
  16. * @covers BlockLevelPass
  17. * @covers CoreParserFunctions
  18. * @covers CoreTagHooks
  19. * @covers Sanitizer
  20. * @covers Preprocessor
  21. * @covers Preprocessor_DOM
  22. * @covers Preprocessor_Hash
  23. * @covers DateFormatter
  24. * @covers LinkHolderArray
  25. * @covers StripState
  26. * @covers ParserOptions
  27. * @covers ParserOutput
  28. */
  29. class ParserIntegrationTest extends PHPUnit\Framework\TestCase {
  30. use MediaWikiCoversValidator;
  31. /** @var array */
  32. private $ptTest;
  33. /** @var ParserTestRunner */
  34. private $ptRunner;
  35. /** @var ScopedCallback */
  36. private $ptTeardownScope;
  37. public function __construct( $runner, $fileName, $test ) {
  38. parent::__construct( 'testParse', [ '[details omitted]' ],
  39. basename( $fileName ) . ': ' . $test['desc'] );
  40. $this->ptTest = $test;
  41. $this->ptRunner = $runner;
  42. }
  43. public function testParse() {
  44. $this->ptRunner->getRecorder()->setTestCase( $this );
  45. $result = $this->ptRunner->runTest( $this->ptTest );
  46. $this->assertEquals( $result->expected, $result->actual );
  47. }
  48. public function setUp() {
  49. $this->ptTeardownScope = $this->ptRunner->staticSetup();
  50. }
  51. public function tearDown() {
  52. if ( $this->ptTeardownScope ) {
  53. ScopedCallback::consume( $this->ptTeardownScope );
  54. }
  55. }
  56. }