forked from dokufreaks/plugin-include
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix local links to not included sections, fixes dokufreaks#108
This transforms local links in an included page into internal links if the page hasn't been fully included. This doesn't consider the case that the target section (but not the full page) has been included at another place in the page as this is considered to be rather unlikely.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
if (!defined('DOKU_INC')) die(); | ||
|
||
/** | ||
* Test the conversion of local links to internal links if the page hasn't been fully included | ||
*/ | ||
class plugin_include_locallink_conversion_test extends DokuWikiTest { | ||
/** @var helper_plugin_include $helper */ | ||
private $helper; | ||
|
||
public function setUp() { | ||
$this->pluginsEnabled[] = 'include'; | ||
parent::setUp(); | ||
|
||
$this->helper = plugin_load('helper', 'include'); | ||
|
||
saveWikiText('included', 'Example content with link [[#jump]]', 'Test setup'); | ||
idx_addPage('test:included'); | ||
|
||
saveWikiText('test:includefull', '{{page>..:included}}', 'Test setup'); | ||
idx_addPage('test:includefull'); | ||
|
||
saveWikiText('test:includefirst', '{{page>..:included&firstseconly}}', 'Test setup'); | ||
idx_addPage('test:includefirst'); | ||
} | ||
|
||
public function testLocalConverted() { | ||
$html = p_wiki_xhtml('test:includefirst'); | ||
$this->assertContains('href="'.wl('included').'#jump"', $html); | ||
$this->assertNotContains('href="#jump"', $html); | ||
} | ||
|
||
public function testLocalExistsIfIncluded() { | ||
$html = p_wiki_xhtml('test:includefull'); | ||
$this->assertContains('href="#jump"', $html); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters