mirror of
https://github.com/dokuwiki/dokuwiki-plugin-xref.git
synced 2025-08-06 10:02:53 +00:00

This implements a mechanism that transforms our current references into search terms understood by Grok. Using the API we can even check if there's any hits (ideally it should be exactly one)
52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace dokuwiki\plugin\xref\test;
|
|
|
|
use dokuwiki\plugin\xref\Heuristics;
|
|
use DokuWikiTest;
|
|
|
|
/**
|
|
* Heuristics tests for the xref plugin
|
|
*
|
|
* @group plugin_xref
|
|
* @group plugins
|
|
*/
|
|
class HeuristicsTest extends DokuWikiTest
|
|
{
|
|
/**
|
|
* @return \string[][]
|
|
* @see testHeuristics
|
|
*/
|
|
public function provideData()
|
|
{
|
|
return [
|
|
['auth.php#auth_setup', 'auth_setup', 'auth.php'],
|
|
['inc/Menu/Item/AbstractItem.php', '', 'inc Menu Item AbstractItem.php'],
|
|
['dokuwiki\Menu\Item\AbstractItem', 'AbstractItem', 'inc Menu Item AbstractItem'],
|
|
['dokuwiki\Menu\Item\AbstractItem::getLabel()', 'getLabel', 'inc Menu Item AbstractItem'],
|
|
['dokuwiki\Menu\Item\AbstractItem->getLabel()', 'getLabel', 'inc Menu Item AbstractItem'],
|
|
['AbstractItem::getLabel()', 'getLabel', 'AbstractItem'],
|
|
['AbstractItem->getLabel()', 'getLabel', 'AbstractItem'],
|
|
['$INFO', 'INFO', ''],
|
|
['foobar()', 'foobar', ''],
|
|
['FooBar()', 'FooBar', ''],
|
|
['AbstractItem', 'AbstractItem', 'AbstractItem'],
|
|
['abstractItem', 'abstractItem', ''],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideData
|
|
* @param string $reference
|
|
* @param string $expDef
|
|
* @param string $expPath
|
|
*/
|
|
public function testHeuristics($reference, $expDef, $expPath)
|
|
{
|
|
$heur = new Heuristics($reference);
|
|
|
|
$this->assertEquals($expDef, $heur->getDef(), 'definition is wrong');
|
|
$this->assertEquals($expPath, $heur->getPath(), 'path is wrong');
|
|
}
|
|
}
|