Files
dokuwiki-plugin-xref/_test/HeuristicsTest.php
Andreas Gohr d4a11906f9 new mechanisms to reference Grok instead of phprxref
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)
2022-01-27 23:12:27 +01:00

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');
}
}