mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 01:39:30 +02:00
Refactor, add Targets class.
This commit is contained in:
20
tests/phpunit/ConfigTest.php
Normal file
20
tests/phpunit/ConfigTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests the LinkTitles\Config class.
|
||||
*
|
||||
* This single unit test basically serves to ensure the Config class is working.
|
||||
* @group bovender
|
||||
* @group Database
|
||||
*/
|
||||
class ConfigTest extends LinkTitles\TestCase {
|
||||
|
||||
public function testParseOnEdit() {
|
||||
$this->setMwGlobals( [
|
||||
'wgLinkTitlesParseOnEdit' => true,
|
||||
'wgLinkTitlesParseOnRender' => false
|
||||
] );
|
||||
$config = new LinkTitles\Config();
|
||||
global $wgLinkTitlesParseOnEdit;
|
||||
$this->assertSame( $config->parseOnEdit, $wgLinkTitlesParseOnEdit );
|
||||
}
|
||||
}
|
@ -8,10 +8,20 @@ class ParseOnEditTest extends LinkTitles\TestCase {
|
||||
public function testParseOnEdit() {
|
||||
$this->setMwGlobals( [
|
||||
'wgLinkTitlesParseOnEdit' => true,
|
||||
'wgLinkTitlesParseOnRender' => true
|
||||
'wgLinkTitlesParseOnRender' => false
|
||||
] );
|
||||
$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 ) );
|
||||
}
|
||||
|
||||
public function testDoNotParseOnEdit() {
|
||||
$this->setMwGlobals( [
|
||||
'wgLinkTitlesParseOnEdit' => false,
|
||||
'wgLinkTitlesParseOnRender' => false
|
||||
] );
|
||||
$pageId = $this->insertPage( 'test page', 'This page should not link to the link target' )['id'];
|
||||
$page = WikiPage::newFromId( $pageId );
|
||||
$this->assertSame( 'This page should not link to the link target', self::getPageText( $page ) );
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ abstract class TestCase extends \MediaWikiTestCase {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->insertPage( 'link target', 'This page serves as a link target' );
|
||||
Extension::invalidateCache();
|
||||
Targets::invalidate(); // force re-querying the pages table
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
|
Reference in New Issue
Block a user