whether it should work
$prefix_texts = array(
'' => true,
"np \n" => true,
'bp text ' => true,
'cp text>' => true,
'ep text.' => array('w' => false), // doesn't work for www. type urls, but for everything else
);
$suffix_texts = array(
'' => true,
"\n ns" => true,
' bs text.' => true,
'>cs text' => true,
'"ds text' => true,
'. es text.' => true,
', fs text.' => true,
);
$urls = array(
'http://example.com' => array('tag' => 'm', 'url' => false, 'text' => false), // false means same as key
'http://example.com/' => array('tag' => 'm', 'url' => false, 'text' => false),
'http://example.com/path?query=abc' => array('tag' => 'm', 'url' => false, 'text' => false),
'http://example.com/1' => array('tag' => 'm', 'url' => false, 'text' => false),
'http://example.com/some/very/long/path/with/over/55/characters?and=a&long=query&too=1' => array('tag' => 'm', 'url' => false, 'text' => 'http://example.com/some/very/long/path/ ... uery&too=1'),
'http://localhost' => array('tag' => 'm', 'url' => false, 'text' => false),
'http://localhost/#abc' => array('tag' => 'm', 'url' => false, 'text' => false),
'www.example.com/path/' => array('tag' => 'w', 'url' => 'http://www.example.com/path/', 'text' => false),
'randomwww.example.com/path/' => false,
'http://thisdomain.org' => array('tag' => 'm', 'url' => false, 'text' => false),
'http://thisdomain.org/' => array('tag' => 'm', 'url' => false, 'text' => false),
'http://thisdomain.org/1' => array('tag' => 'l', 'url' => false, 'text' => '1'),
'http://thisdomain.org/path/some?query=abc#test' => array('tag' => 'l', 'url' => false, 'text' => 'path/some?query=abc#test'),
'javascript:www.example.com/' => false,
);
$test_data = array();
// run the test for each combination
foreach ($prefix_texts as $prefix => $prefix_success)
{
foreach ($suffix_texts as $suffix => $suffix_success)
{
foreach ($urls as $url => $url_type)
{
$input = $prefix . $url . $suffix;
// no valid url => no change
$output = $input;
if (
($prefix_success && $suffix_success && is_array($url_type)) &&
// handle except syntax for prefix/suffix
(!is_array($prefix_success) || !isset($prefix_success[$url_type['tag']]) || $prefix_success[$url_type['tag']] == true) &&
(!is_array($suffix_success) || !isset($suffix_success[$url_type['tag']]) || $suffix_success[$url_type['tag']] == true)
)
{
// false means it's the same as the url, less typing
$url_type['url'] = ($url_type['url']) ? $url_type['url'] : $url;
$url_type['text'] = ($url_type['text']) ? $url_type['text'] : $url;
$class = ($url_type['tag'] === 'l') ? 'postlink-local' : 'postlink';
// replace the url with the desired output format
$output = $prefix . '' . $url_type['text'] . '' . $suffix;
}
$test_data[] = array($input, $output);
}
}
}
return $test_data;
}
/**
* @dataProvider make_clickable_data
*/
public function test_make_clickable($input, $expected)
{
$result = make_clickable($input, 'http://thisdomain.org');
$label = 'Making text clickable: ' . $input;
$this->assertEquals($expected, $result, $label);
}
}
vٯ<$UEl3VPݵC,49"nzG(T9;я\maR_jLQ`?Y';2-EdKtllу˯ s7֎mB+ $H( %#,ө
X
ǧǞ5 ̢(&Qv{[Ncc9k~3r٨b%)L|t(,:~P||+>dj>`EH=d}gz懶 ܷvBJ=bQ/n(TvDki#hûeo} %BX"iP?mO"f xߝ:o6cDeYAWv'&^|.)4Bz>Y<}-)t{K;nC(0?KC-Y8c.
7Z7&Ys焎~QFxĕZXWc3LYY}AzɪMtWT5HB]x805z,FVVqUr4l콧f!U 4(ì+s
}2QctƮt[Մޑ;̳
耚zE_$Q]L-*'b:i˃}i\Vux
(*Dt
ak-ȥ!Űf3zh~V8ڊU>~!̭IP$Zq'kF*mmU<{ap*a.ZL)Xm6
:*Z HgZuUĥWV[3>%c.o:ٜҝY?z qݚ1 VIGHAWzl-Jrp.#Y4l1.x[`a:Y"!ʠDЌ6ºT%erwގdIIfX&g51ٮ30 LՏgD@DӅL6]|2+Rп9%{X(
v?`!B3TRE;ӅE9W]l6ט1y,ՑP5\V6͊[7n;PjnW1i(.%5^r@.1~>Uj2]c7u[o}[e+{a浢ڞ/NIn#E{ݱtE(85QGM3|rDhVf2@:ːYxi 6BLS$7>j>|L4"wF =9~-uځJw<`7yPc@ߟF1nmQA|c,o
pe zڲW*=9 s
wPH;R#7I/~c8Sګ:y=NWk5^ViC7"t8AlqK'
1HݍyPJaXsA}mKl9Њ@І+<''Iϝ)}ė#,Mh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