<?php 
include '../httpdocs/wp-includes/kses.php';
include '../httpdocs/wp-includes/formatting.php';
function apply_filters($ignore, $x )
{
	return $x;
}
function add_action() {}

class TestMakeClickable extends PHPUnit_Framework_TestCase {

	protected function setUp()
	{
	}

	protected function tearDown()
	{
	}

	/**
	 * @dataProvider provider__make_clickable
	 */
	public function test__make_clickable( $orig_string, $accurately_clickable )
	{
		$this->assertEquals(
			$accurately_clickable,
			make_clickable( $orig_string )
		);
	}

	public function provider__make_clickable()
	{
		return array(
			array(
				'There was a spoon named (http://wordpress.org)',
				'There was a spoon named (<a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>)',
			),

			array(
				'There was a spoon named (http://wordpress.org)x',
				'There was a spoon named (<a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>)x',
			),

			array(
				'blah blah blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software) blah blah',
				'blah blah blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a> blah blah',
			),

			array(
				'blah blah blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) blah blah',
				'blah blah blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>) blah blah',
			),

			array(
				'blah blah (http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) blah blah',
				'blah blah (<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>) blah blah',
			),

			array(
				'blah blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software).) blah blah',
				'blah blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>.) blah blah',
			),

			array(
				'blah blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software).)moreurl blah blah',
				'blah blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>.)moreurl blah blah',
			),

			array(
				'blah blah There was a spoon named http://wordpress.org.',
				'blah blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>.',
			),

			array(
				'blah (blah There was a spoon named http://wordpress.org.) blah',
				'blah (blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>.) blah',
			),

			array(
				'blah blah There was a spoon named http://wordpress.org. [EOL char here]',
				'blah blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>. [EOL char here]',
			),

			array(
				'blah blah There was a spoon named http://wordpress.org.',
				'blah blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>.',
			),

			array(
				'blah blah There was a spoon named http://wordpress.org. blah blah',
				'blah blah There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>. blah blah',
			),

			array(
				'blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software) blah blah',
				'blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a> blah blah',
			),

			array(
				'blah http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx blah blah',
				'blah <a href="http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx</a> blah blah',
			),

			array(
				'blah My site (http://josephscott.org) blah blah',
				'blah My site (<a href="http://josephscott.org" rel="nofollow">http://josephscott.org</a>) blah blah',
			),

			array(
				'blah My (http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) article blah blah',
				'blah My (<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>) article blah blah',
			),

			array(
				'Example: WordPress, test (some text), I love example.com (http://example.org), it is brilliant',
				'Example: WordPress, test (some text), I love example.com (<a href="http://example.org" rel="nofollow">http://example.org</a>), it is brilliant',
			),

			array(
				'http://twitter.com/#!/wordpress/status/25907440233',
				'<a href="http://twitter.com/#!/wordpress/status/25907440233" rel="nofollow">http://twitter.com/#!/wordpress/status/25907440233</a>',
			),

			// from the WP test suite:
			array(
				'http://wordpress.org/hello.html',
				'<a href="http://wordpress.org/hello.html" rel="nofollow">http://wordpress.org/hello.html</a>',
			),

			array(
				'There was a spoon named http://wordpress.org. Alice!',
				'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>. Alice!',
			),

			array(
				'There was a spoon named http://wordpress.org, said Alice.',
				'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>, said Alice.',
			),

			array(
				'There was a spoon named http://wordpress.org; said Alice.',
				'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>; said Alice.',
			),

			array(
				'There was a spoon named http://wordpress.org: said Alice.',
				'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>: said Alice.',
			),

			array(
				'There was a spoon named (http://wordpress.org) said Alice.',
				'There was a spoon named (<a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>) said Alice.',
			),
				
			array(
				'http://wordpress.org/hello.html',
				'<a href="http://wordpress.org/hello.html" rel="nofollow">http://wordpress.org/hello.html</a>',
			),

			array(
				'There was a spoon named http://wordpress.org.',
				'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>.',
			),

			array(
				'There was a spoon named http://wordpress.org,',
				'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>,',
			),

			array(
				'There was a spoon named http://wordpress.org;',
				'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>;',
			),

			array(
				'There was a spoon named http://wordpress.org:',
				'There was a spoon named <a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>:',
			),

			array(
				'There was a spoon named (http://wordpress.org)',
				'There was a spoon named (<a href="http://wordpress.org" rel="nofollow">http://wordpress.org</a>)',
			),
			
			array(
				'www.wordpress.org',
				'<a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>',
			),

			array(
				'There was a spoon named www.wordpress.org. Alice!',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>. Alice!',
			),

			array(
				'There was a spoon named www.wordpress.org, said Alice.',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>, said Alice.',
			),

			array(
				'There was a spoon named www.wordpress.org; said Alice.',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>; said Alice.',
			),

			array(
				'There was a spoon named www.wordpress.org: said Alice.',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>: said Alice.',
			),

			array(
				'There was a spoon named www.wordpress.org) said Alice.',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>) said Alice.',
			),
			
			array(
				'www.wordpress.org',
				'<a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>',
			),
			
			array(
				'There was a spoon named www.wordpress.org.',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>.',
			),
			
			array(
				'There was a spoon named www.wordpress.org,',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>,',
			),
			
			array(
				'There was a spoon named www.wordpress.org;',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>;',
			),
			
			array(
				'There was a spoon named www.wordpress.org:',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>:',
			),
			
			array(
				'There was a spoon named www.wordpress.org)',
				'There was a spoon named <a href="http://www.wordpress.org" rel="nofollow">http://www.wordpress.org</a>)'
			),
				
			array(
				'http://www.詹姆斯.com/',
				'<a href="http://www.詹姆斯.com/" rel="nofollow">http://www.詹姆斯.com/</a>',
			),
			array(
				'http://bg.wikipedia.org/Баба',
				'<a href="http://bg.wikipedia.org/Баба" rel="nofollow">http://bg.wikipedia.org/Баба</a>',
			),

			array(
				'http://example.com/?a=баба&b=дядо',
				'<a href="http://example.com/?a=баба&#038;b=дядо" rel="nofollow">http://example.com/?a=баба&#038;b=дядо</a>',
			),
				
			array(
				'http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)',
				'<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>',
			),
			array(
				'(http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software))',
				'(<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>)',
			),
			array(
				'blah http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software) blah',
				'blah <a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a> blah',
			),
			array(
				'blah (http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)) blah',
				'blah (<a href="http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)" rel="nofollow">http://en.wikipedia.org/wiki/PC_Tools_(Central_Point_Software)</a>) blah',
			),
			array(
				'Example: WordPress, test (some text), I love example.com (http://example.org), it is brilliant',
				'Example: WordPress, test (some text), I love example.com (<a href="http://example.org" rel="nofollow">http://example.org</a>), it is brilliant',
			),
			array(
				'Example: WordPress, test (some text), I love example.com (http://example.com), it is brilliant',
				'Example: WordPress, test (some text), I love example.com (<a href="http://example.com" rel="nofollow">http://example.com</a>), it is brilliant',
			),
			array(
				'Some text followed by a bracketed link with a trailing elipsis (http://example.com)...',
				'Some text followed by a bracketed link with a trailing elipsis (<a href="http://example.com" rel="nofollow">http://example.com</a>)...',
			),
		);
	}
}
