mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
First working test.
This commit is contained in:
17
tests/phpunit/ParseOnEditTest.php
Normal file
17
tests/phpunit/ParseOnEditTest.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* @group bovender
|
||||
* @group Database
|
||||
*/
|
||||
class ParseOnEditTest extends LinkTitles\TestCase {
|
||||
|
||||
public function testParseOnEdit() {
|
||||
$this->setMwGlobals( [
|
||||
'wgLinkTitlesParseOnEdit' => true,
|
||||
'wgLinkTitlesParseOnRender' => true
|
||||
] );
|
||||
$pageId = $this->insertPage( 'test page', 'This page should link to the link target' )['id'];
|
||||
$page = WikiPage::newFromId( $pageId );
|
||||
$this->assertSame( 'This page should link to the [[link target]]', self::getPageText( $page ) );
|
||||
}
|
||||
}
|
19
tests/phpunit/TestCase.php
Normal file
19
tests/phpunit/TestCase.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace LinkTitles;
|
||||
|
||||
abstract class TestCase extends \MediaWikiTestCase {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->insertPage( 'link target', 'This page serves as a link target' );
|
||||
Extension::invalidateCache();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function getPageText( \WikiPage $page ) {
|
||||
$content = $page->getContent();
|
||||
return $page->getContentHandler()->serializeContent( $content );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user