| 107 | | like( $html, qr|<a href="wiki.pl\?Extended_Link">Extended Link</a>|, |
| 108 | | "extended links work" ); |
| 109 | | like( $html, qr|<a href="wiki.pl\?Extended_Link">extended link</a>|, |
| 110 | | "...and are forced ucfirst" ); |
| 111 | | like( $html, qr|<a href="wiki.pl\?Extended_Link">titled extended link</a>|, |
| 112 | | "...and titles work" ); |
| 113 | | like( $html, qr|[^ ]title with leading whitespace|, |
| 114 | | "...and don't show leading whitespace" ); |
| 115 | | like( $html, qr|<a href="wiki.pl\?Extended_Link_Two">|, |
| 116 | | "...and titled nodes with trailing whitespace are munged correctly before formatting" ); |
| | 98 | my $wiki = Test::MockObject->new; |
| | 99 | $wiki->mock( "node_exists", |
| | 100 | sub { |
| | 101 | my ($self, $node) = @_; |
| | 102 | if ( $node eq "Extended Link" |
| | 103 | or $node eq "Extended Link Two" |
| | 104 | or $node eq "Another Link" ) { |
| | 105 | return 1; |
| | 106 | } else { |
| | 107 | return 0; |
| | 108 | } |
| | 109 | } |
| | 110 | ); |
| 122 | | like( $html, qr|<a href="wiki.pl\?Extended%20Link">Extended Link</a>|, |
| 123 | | "extended links work with unmunged URLs" ); |
| 124 | | like( $html, qr|<a href="wiki.pl\?Extended%20Link">extended link</a>|, |
| 125 | | "...and are forced ucfirst" ); |
| 126 | | like( $html, qr|<a href="wiki.pl\?Extended%20Link">titled extended link</a>|, |
| 127 | | "...and titles work" ); |
| | 117 | like( $html, qr|<a href="wiki.pl\?Extended_Link">Extended Link</a>|, |
| | 118 | "extended links work" ); |
| | 119 | like( $html, qr|<a href="wiki.pl\?Extended_Link">extended link</a>|, |
| | 120 | "...and are forced ucfirst" ); |
| | 121 | like( $html, qr|<a href="wiki.pl\?Extended_Link">titled extended link</a>|, |
| | 122 | "...and titles work" ); |
| | 123 | like( $html, qr|[^ ]title with leading whitespace|, |
| | 124 | "...and don't show leading whitespace" ); |
| | 125 | like( $html, qr|<a href="wiki.pl\?Extended_Link_Two">|, |
| | 126 | "...and titled nodes with trailing whitespace are munged correctly " |
| | 127 | . "before formatting" ); |
| 129 | | @links = $formatter->find_internal_links($wikitext); |
| 130 | | print "# Found links: " . join(", ", @links) . "\n"; |
| 131 | | my %linkhash = map { $_ => 1 } @links; |
| 132 | | ok( ! defined $linkhash{"extended link"}, |
| 133 | | "find_internal_links respects ucfirst" ); |
| 134 | | ok( ! defined $linkhash{"Extended Link "}, |
| 135 | | "...and drops trailing whitespace" ); |
| 136 | | is_deeply( \@links, [ "Extended Link", "Extended Link", "Extended Link", "Extended Link Two", "Another Link" ], "...and gets the right order" ); |
| | 129 | # Test with unmunged URLs. |
| | 130 | $formatter = Wiki::Toolkit::Formatter::UseMod->new( extended_links => 1 ); |
| | 131 | $html = $formatter->format($wikitext, $wiki); |
| | 132 | |
| | 133 | like( $html, qr|<a href="wiki.pl\?Extended%20Link">Extended Link</a>|, |
| | 134 | "extended links work with unmunged URLs" ); |
| | 135 | like( $html, qr|<a href="wiki.pl\?Extended%20Link">extended link</a>|, |
| | 136 | "...and are forced ucfirst" ); |
| | 137 | like( $html, |
| | 138 | qr|<a href="wiki.pl\?Extended%20Link">titled extended link</a>|, |
| | 139 | "...and titles work" ); |
| | 140 | |
| | 141 | @links = $formatter->find_internal_links($wikitext); |
| | 142 | print "# Found links: " . join(", ", @links) . "\n"; |
| | 143 | my %linkhash = map { $_ => 1 } @links; |
| | 144 | ok( ! defined $linkhash{"extended link"}, |
| | 145 | "find_internal_links respects ucfirst" ); |
| | 146 | ok( ! defined $linkhash{"Extended Link "}, |
| | 147 | "...and drops trailing whitespace" ); |
| | 148 | is_deeply( \@links, |
| | 149 | [ "Extended Link", "Extended Link", "Extended Link", |
| | 150 | "Extended Link Two", "Another Link" ], |
| | 151 | "...and gets the right order" ); |
| | 152 | } |