mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Fix tests.
This commit is contained in:
@ -37,7 +37,8 @@
|
|||||||
class LinkTitlesLinkerTest extends LinkTitles\TestCase {
|
class LinkTitlesLinkerTest extends LinkTitles\TestCase {
|
||||||
protected $title;
|
protected $title;
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp(): void
|
||||||
|
{
|
||||||
parent::setUp(); // call last to have the Targets object invalidated after inserting the page
|
parent::setUp(); // call last to have the Targets object invalidated after inserting the page
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,13 +316,13 @@ class LinkTitlesLinkerTest extends LinkTitles\TestCase {
|
|||||||
|
|
||||||
// Reset namespace caches.
|
// Reset namespace caches.
|
||||||
// See https://stackoverflow.com/q/45974979/270712
|
// See https://stackoverflow.com/q/45974979/270712
|
||||||
MWNamespace::getCanonicalNamespaces( true );
|
\MWNamespace::getCanonicalNamespaces(true);
|
||||||
global $wgContLang;
|
global $wgContLang;
|
||||||
$wgContLang->resetNamespaces();
|
$wgContLang->resetNamespaces();
|
||||||
$this->assertTrue( MWNamespace::exists( $ns ), "The namespace with id $ns should exist!" );
|
$this->assertTrue( MWNamespace::exists( $ns ), "The namespace with id $ns should exist!" );
|
||||||
|
|
||||||
$this->insertPage( "in custom namespace", 'This is a page in a custom namespace', $ns );
|
$this->insertPage( "in custom namespace", 'This is a page in a custom namespace', $ns );
|
||||||
LinKTitles\Targets::invalidate();
|
LinkTitles\Targets::invalidate();
|
||||||
$linker = new LinkTitles\Linker( $config );
|
$linker = new LinkTitles\Linker( $config );
|
||||||
$source = LinkTitles\Source::createFromTitleAndText( $this->title, $input, $config );
|
$source = LinkTitles\Source::createFromTitleAndText( $this->title, $input, $config );
|
||||||
$result = $linker->linkContent( $source );
|
$result = $linker->linkContent( $source );
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2012-2018 Daniel Kraus <bovender@bovender.de> ('bovender')
|
* Copyright 2012-2018 Daniel Kraus <bovender@bovender.de> ('bovender')
|
||||||
*
|
*
|
||||||
@ -25,11 +26,13 @@
|
|||||||
*
|
*
|
||||||
* @group bovender
|
* @group bovender
|
||||||
*/
|
*/
|
||||||
class SplitterTest extends MediaWikiTestCase {
|
class SplitterTest extends \MediaWikiTestCase
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideSplitData
|
* @dataProvider provideSplitData
|
||||||
*/
|
*/
|
||||||
public function testSplit( $skipTemplates, $parseHeadings, $input, $expectedOutput ) {
|
public function testSplit($skipTemplates, $parseHeadings, $input, $expectedOutput)
|
||||||
|
{
|
||||||
$config = new LinkTitles\Config();
|
$config = new LinkTitles\Config();
|
||||||
$config->skipTemplates = $skipTemplates;
|
$config->skipTemplates = $skipTemplates;
|
||||||
$config->parseHeadings = $parseHeadings;
|
$config->parseHeadings = $parseHeadings;
|
||||||
@ -41,7 +44,8 @@ class SplitterTest extends MediaWikiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add more examples.
|
// TODO: Add more examples.
|
||||||
public static function provideSplitData() {
|
public static function provideSplitData()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
true, // skipTemplates
|
true, // skipTemplates
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2012-2018 Daniel Kraus <bovender@bovender.de> ('bovender')
|
* Copyright 2012-2018 Daniel Kraus <bovender@bovender.de> ('bovender')
|
||||||
*
|
*
|
||||||
@ -23,19 +24,22 @@
|
|||||||
/**
|
/**
|
||||||
* @group bovender
|
* @group bovender
|
||||||
*/
|
*/
|
||||||
class TargetTest extends MediaWikiTestCase {
|
class TargetTest extends \MediaWikiTestCase
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideStartOnly
|
* @dataProvider provideStartOnly
|
||||||
*/
|
*/
|
||||||
public function testTargetWordStartOnly( $enabled, $delimiter ) {
|
public function testTargetWordStartOnly($enabled, $delimiter)
|
||||||
|
{
|
||||||
$config = new LinkTitles\Config();
|
$config = new LinkTitles\Config();
|
||||||
$config->wordStartOnly = $enabled;
|
$config->wordStartOnly = $enabled;
|
||||||
$target = new LinKTitles\Target(NS_MAIN, 'test page', $config);
|
$target = new LinKTitles\Target(NS_MAIN, 'test page', $config);
|
||||||
$this->assertSame($delimiter, $target->wordStart);
|
$this->assertSame($delimiter, $target->wordStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideStartOnly() {
|
public static function provideStartOnly()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
[true, '(?<!\pL|\pN)'],
|
[true, '(?<!\pL|\pN)'],
|
||||||
[false, '']
|
[false, '']
|
||||||
@ -45,14 +49,16 @@ class TargetTest extends MediaWikiTestCase {
|
|||||||
/**
|
/**
|
||||||
* @dataProvider provideEndOnly
|
* @dataProvider provideEndOnly
|
||||||
*/
|
*/
|
||||||
public function testTargetWordEndOnly( $enabled, $delimiter ) {
|
public function testTargetWordEndOnly($enabled, $delimiter)
|
||||||
|
{
|
||||||
$config = new LinkTitles\Config();
|
$config = new LinkTitles\Config();
|
||||||
$config->wordEndOnly = $enabled;
|
$config->wordEndOnly = $enabled;
|
||||||
$target = new LinKTitles\Target(NS_MAIN, 'test page', $config);
|
$target = new LinKTitles\Target(NS_MAIN, 'test page', $config);
|
||||||
$this->assertSame($delimiter, $target->wordEnd);
|
$this->assertSame($delimiter, $target->wordEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideEndOnly() {
|
public static function provideEndOnly()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
[true, '(?!\pL|\pN)'],
|
[true, '(?!\pL|\pN)'],
|
||||||
[false, '']
|
[false, '']
|
||||||
|
@ -22,11 +22,13 @@
|
|||||||
namespace LinkTitles;
|
namespace LinkTitles;
|
||||||
|
|
||||||
abstract class TestCase extends \MediaWikiTestCase {
|
abstract class TestCase extends \MediaWikiTestCase {
|
||||||
protected function setUp() {
|
protected function setUp(): void
|
||||||
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown() {
|
protected function tearDown(): void
|
||||||
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user