correctly with a typical payload?
$this->assertEquals("Geraldine posted a Photo on PhotoPanic
\n " .
- "", trim($act->content));
+ "", trim($act->content));
}
public function testExample3()
{
global $_example3;
- $dom = DOMDocument::loadXML($_example3);
+ $dom = new DOMDocument();
+ $dom->loadXML($_example3);
$feed = $dom->documentElement;
@@ -116,7 +145,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
public function testExample4()
{
global $_example4;
- $dom = DOMDocument::loadXML($_example4);
+ $dom = new DOMDocument();
+ $dom->loadXML($_example4);
$entry = $dom->documentElement;
@@ -134,7 +164,7 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
$this->assertFalse(empty($act->objects[0]));
$this->assertEquals($act->objects[0]->content,
- '@evan now is the time for all good men to come to the aid of their country. #thetime');
+ '@evan now is the time for all good men to come to the aid of their country. #thetime');
$this->assertFalse(empty($act->actor));
}
@@ -142,7 +172,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
public function testExample5()
{
global $_example5;
- $dom = DOMDocument::loadXML($_example5);
+ $dom = new DOMDocument();
+ $dom->loadXML($_example5);
$feed = $dom->documentElement;
@@ -167,8 +198,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
$avatars = $act->actor->avatarLinks;
$this->assertEquals(
- $avatars[0]->url,
- 'http://example.net/mysite/avatar/3-96-20100224004207.jpeg'
+ $avatars[0]->url,
+ 'http://example.net/mysite/avatar/3-96-20100224004207.jpeg'
);
$this->assertEquals($act->actor->displayName, 'Test User');
@@ -186,7 +217,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
{
global $_example6;
- $dom = DOMDocument::loadXML($_example6);
+ $dom = new DOMDocument();
+ $dom->loadXML($_example6);
$rss = $dom->documentElement;
@@ -217,7 +249,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
{
global $_example7;
- $dom = DOMDocument::loadXML($_example7);
+ $dom = new DOMDocument();
+ $dom->loadXML($_example7);
$rss = $dom->documentElement;
@@ -249,7 +282,7 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
$this->assertTrue(is_array($actor->avatarLinks));
$this->assertEquals(1, count($actor->avatarLinks));
$this->assertEquals('http://files.posterous.com/user_profile_pics/480326/2009-08-05-142447.jpg',
- $actor->avatarLinks[0]->url);
+ $actor->avatarLinks[0]->url);
$this->assertNotNull($actor->poco);
$this->assertEquals('evanpro', $actor->poco->preferredUsername);
$this->assertEquals('Evan Prodromou', $actor->poco->displayName);
@@ -262,7 +295,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
public function testExample8()
{
global $_example8;
- $dom = DOMDocument::loadXML($_example8);
+ $dom = new DOMDocument();
+ $dom->loadXML($_example8);
$feed = $dom->documentElement;
@@ -350,32 +384,33 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
public function testAtomContent()
{
$tests = array(array("Some regular plain text.",
- "Some regular plain text."),
- array("<b>this is not HTML</b>",
- "<b>this is not HTML</b>"),
- array("Some regular plain HTML.",
- "Some regular plain HTML."),
- array("<b>this is too HTML</b>",
- "this is too HTML"),
- array("<b>but this is not HTML!</b>",
- "<b>but this is not HTML!</b>"),
- array("Some regular plain XHTML.
",
- "Some regular plain XHTML."),
- array("This is some XHTML!
",
- "This is some XHTML!"),
- array("<b>This is not some XHTML!</b>
",
- "<b>This is not some XHTML!</b>"),
- array("<b>This is not some XHTML either!</b>
",
- "<b>This is not some XHTML either!</b>"));
+ "Some regular plain text."),
+ array("<b>this is not HTML</b>",
+ "<b>this is not HTML</b>"),
+ array("Some regular plain HTML.",
+ "Some regular plain HTML."),
+ array("<b>this is too HTML</b>",
+ "this is too HTML"),
+ array("<b>but this is not HTML!</b>",
+ "<b>but this is not HTML!</b>"),
+ array("Some regular plain XHTML.
",
+ "Some regular plain XHTML."),
+ array("This is some XHTML!
",
+ "This is some XHTML!"),
+ array("<b>This is not some XHTML!</b>
",
+ "<b>This is not some XHTML!</b>"),
+ array("<b>This is not some XHTML either!</b>
",
+ "<b>This is not some XHTML either!</b>"));
foreach ($tests as $data) {
list($source, $output) = $data;
$xml = "" .
- "http://example.com/fakeid" .
- "Test" .
- "Atom content tests" .
- $source .
- "";
- $dom = DOMDocument::loadXML($xml);
+ "http://example.com/fakeid" .
+ "Test" .
+ "Atom content tests" .
+ $source .
+ "";
+ $dom = new DOMDocument();
+ $dom->loadXML($xml);
$act = new Activity($dom->documentElement);
$this->assertFalse(empty($act));
@@ -386,25 +421,26 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
public function testRssContent()
{
$tests = array(array("Some regular plain HTML.",
- "Some regular plain HTML."),
- array("Some <b>exciting bold HTML</b>",
- "Some exciting bold HTML"),
- array("Some <b>escaped non-HTML.</b>",
- "Some <b>escaped non-HTML.</b>"),
- array("Some plain text.",
- "Some plain text."),
- array("Some <b>non-HTML text</b>",
- "Some <b>non-HTML text</b>"),
- array("Some <b>double-escaped text</b>",
- "Some <b>double-escaped text</b>"));
+ "Some regular plain HTML."),
+ array("Some <b>exciting bold HTML</b>",
+ "Some exciting bold HTML"),
+ array("Some <b>escaped non-HTML.</b>",
+ "Some <b>escaped non-HTML.</b>"),
+ array("Some plain text.",
+ "Some plain text."),
+ array("Some <b>non-HTML text</b>",
+ "Some <b>non-HTML text</b>"),
+ array("Some <b>double-escaped text</b>",
+ "Some <b>double-escaped text</b>"));
foreach ($tests as $data) {
list($source, $output) = $data;
$xml = "- " .
- "http://example.com/fakeid" .
- "RSS content tests" .
- $source .
- "
";
- $dom = DOMDocument::loadXML($xml);
+ "http://example.com/fakeid" .
+ "RSS content tests" .
+ $source .
+ "";
+ $dom = new DOMDocument();
+ $dom->loadXML($xml);
$act = new Activity($dom->documentElement);
$this->assertFalse(empty($act));
diff --git a/tests/Core/CallableLeftCurryTest.php b/tests/Core/CallableLeftCurryTest.php
new file mode 100644
index 0000000000..b3eeea33dc
--- /dev/null
+++ b/tests/Core/CallableLeftCurryTest.php
@@ -0,0 +1,91 @@
+.
+
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . "/lib/callableleftcurry.php";
+
+final class CallableLeftCurryTest extends TestCase
+{
+ /**
+ * @dataProvider provider
+ * @param $callback_test
+ * @param $curry_params
+ * @param $call_params
+ * @param $expected
+ */
+ public function testCallableLeftCurry($callback_test, $curry_params, $call_params, $expected)
+ {
+ $params = array_merge([$callback_test], $curry_params);
+ $curried = call_user_func_array('callableLeftCurry', $params);
+ $result = call_user_func_array($curried, $call_params);
+ $this->assertEquals($expected, $result);
+ }
+
+ static public function provider()
+ {
+ $obj = new CurryTestHelperObj('oldval');
+ return [[['Tests\Unit\CallableLeftCurryTest', 'callback_test'],
+ ['curried'],
+ ['called'],
+ 'called|curried'],
+ [['Tests\Unit\CallableLeftCurryTest', 'callback_test'],
+ ['curried1', 'curried2'],
+ ['called1', 'called2'],
+ 'called1|called2|curried1|curried2'],
+ [['Tests\Unit\CallableLeftCurryTest', 'callback_testObj'],
+ [$obj],
+ ['newval1'],
+ 'oldval|newval1'],
+ // Confirm object identity is retained...
+ [['Tests\Unit\CallableLeftCurryTest', 'callback_testObj'],
+ [$obj],
+ ['newval2'],
+ 'newval1|newval2']];
+ }
+
+ static function callback_test()
+ {
+ $args = func_get_args();
+ return implode("|", $args);
+ }
+
+ static function callback_testObj($val, $obj)
+ {
+ $old = $obj->val;
+ $obj->val = $val;
+ return "$old|$val";
+ }
+}
+
+class CurryTestHelperObj
+{
+ public $val = '';
+
+ function __construct($val)
+ {
+ $this->val = $val;
+ }
+}
diff --git a/tests/CommandInterperterTest.php b/tests/Core/CommandInterperterTest.php
similarity index 79%
rename from tests/CommandInterperterTest.php
rename to tests/Core/CommandInterperterTest.php
index 5f681ae1da..d8f6149a7c 100644
--- a/tests/CommandInterperterTest.php
+++ b/tests/Core/CommandInterperterTest.php
@@ -1,23 +1,46 @@
.
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
}
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('GNUSOCIAL', true);
-define('STATUSNET', true); // compatibility
+use CommandInterpreter;
+use PHPUnit\Framework\TestCase;
require_once INSTALLDIR . '/lib/common.php';
-class CommandInterpreterTest extends PHPUnit_Framework_TestCase
+final class CommandInterpreterTest extends TestCase
{
/**
* @dataProvider commandInterpreterCases
+ * @param $input
+ * @param $expectedType
+ * @param string $comment
*/
- public function testCommandInterpreter($input, $expectedType, $comment='')
+ public function testCommandInterpreter($input, $expectedType, $comment = '')
{
$inter = new CommandInterpreter();
@@ -130,9 +153,9 @@ class CommandInterpreterTest extends PHPUnit_Framework_TestCase
array('whois foo', 'WhoisCommand'),
array('whois foo bar', null),
-/* array('fav', null),
- array('fav foo', 'FavCommand'),
- array('fav foo bar', null),*/
+ /* array('fav', null),
+ array('fav foo', 'FavCommand'),
+ array('fav foo bar', null),*/
array('nudge', null),
array('nudge foo', 'NudgeCommand'),
diff --git a/tests/Core/HashTagDetectionTests.php b/tests/Core/HashTagDetectionTests.php
new file mode 100644
index 0000000000..00b312545d
--- /dev/null
+++ b/tests/Core/HashTagDetectionTests.php
@@ -0,0 +1,83 @@
+.
+
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
+}
+
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class HashTagDetectionTests extends TestCase
+{
+ /**
+ * @dataProvider provider
+ * @param $content
+ * @param $expected
+ */
+ public function testProduction($content, $expected)
+ {
+ $rendered = common_render_text($content);
+ $this->assertEquals($expected, $rendered);
+ }
+
+ static public function provider()
+ {
+ return array(
+ array('hello',
+ 'hello'),
+ array('#hello people',
+ '#hello people'),
+ array('"#hello" people',
+ '"#hello" people'),
+ array('say "#hello" people',
+ 'say "#hello" people'),
+ array('say (#hello) people',
+ 'say (#hello) people'),
+ array('say [#hello] people',
+ 'say [#hello] people'),
+ array('say {#hello} people',
+ 'say {#hello} people'),
+ array('say \'#hello\' people',
+ 'say \'#hello\' people'),
+
+ // Unicode legit letters
+ array('#éclair yummy',
+ '#éclair yummy'),
+ array('#维基百科 zh.wikipedia!',
+ '#维基百科 zh.wikipedia!'),
+ array('#Россия russia',
+ '#Россия russia'),
+
+ // Unicode punctuators -- the ideographic "," separates the tag, just as "," does
+ array('#维基百科,zh.wikipedia!',
+ '#维基百科,zh.wikipedia!'),
+ array('#维基百科,zh.wikipedia!',
+ '#维基百科,zh.wikipedia!'),
+
+ );
+ }
+}
+
diff --git a/tests/Core/LocationTest.php b/tests/Core/LocationTest.php
new file mode 100644
index 0000000000..747a470d9d
--- /dev/null
+++ b/tests/Core/LocationTest.php
@@ -0,0 +1,124 @@
+.
+
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
+}
+
+use GeonamesPlugin;
+use Location;
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+// Make sure this is loaded
+// XXX: how to test other plugins...?
+
+addPlugin('Geonames');
+
+final class LocationTest extends TestCase
+{
+
+ /**
+ * @dataProvider locationNames
+ * @param $name
+ * @param $language
+ * @param $location
+ */
+
+ public function testLocationFromName($name, $language, $location)
+ {
+ $result = Location::fromName($name, $language);
+ $this->assertEquals($result, $location);
+ }
+
+ static public function locationNames()
+ {
+ return array(array('Montreal', 'en', null),
+ array('San Francisco, CA', 'en', null),
+ array('Paris, France', 'en', null),
+ array('Paris, Texas', 'en', null));
+ }
+
+ /**
+ * @dataProvider locationIds
+ * @param $id
+ * @param $ns
+ * @param $language
+ * @param $location
+ */
+
+ public function testLocationFromId($id, $ns, $language, $location)
+ {
+ $result = Location::fromId($id, $ns, $language);
+ $this->assertEquals($result, $location);
+ }
+
+ static public function locationIds()
+ {
+ return array(array(6077243, GeonamesPlugin::LOCATION_NS, 'en', null),
+ array(5391959, GeonamesPlugin::LOCATION_NS, 'en', null));
+ }
+
+ /**
+ * @dataProvider locationLatLons
+ * @param $lat
+ * @param $lon
+ * @param $language
+ * @param $location
+ */
+
+ public function testLocationFromLatLon($lat, $lon, $language, $location)
+ {
+ $result = Location::fromLatLon($lat, $lon, $language);
+ $this->assertEquals($location, $result->location_id);
+ }
+
+ static public function locationLatLons()
+ {
+ return array(array(37.77493, -122.41942, 'en', null),
+ array(45.509, -73.588, 'en', null));
+ }
+
+ /**
+ * @dataProvider nameOfLocation
+ * @param $location
+ * @param $language
+ * @param $name
+ */
+
+ public function testLocationGetName($location, $language, $name)
+ {
+ $result = empty($location) ? null : $location->getName($language);
+ $this->assertEquals($name, $result);
+ }
+
+ static public function nameOfLocation()
+ {
+ $loc = Location::fromName('Montreal', 'en');
+ return array(array($loc, 'en', null), //'Montreal'),
+ array($loc, 'fr', null));//'Montréal'));
+ }
+}
+
diff --git a/tests/Core/NicknameTest.php b/tests/Core/NicknameTest.php
new file mode 100644
index 0000000000..e315033bbb
--- /dev/null
+++ b/tests/Core/NicknameTest.php
@@ -0,0 +1,156 @@
+.
+
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
+}
+
+use Nickname;
+use NicknameBlacklistedException;
+use NicknameEmptyException;
+use NicknameException;
+use NicknameInvalidException;
+use NicknamePathCollisionException;
+use NicknameTakenException;
+use NicknameTooLongException;
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+/**
+ * Test cases for nickname validity and normalization.
+ */
+final class NicknameTest extends TestCase
+{
+ /**
+ * Basic test using Nickname::normalize()
+ *
+ * @dataProvider provider
+ * @param $input
+ * @param $expected
+ * @param null $expectedException
+ */
+ public function testBasic($input, $expected, $expectedException = null)
+ {
+ $exception = null;
+ $normalized = false;
+ try {
+ $normalized = Nickname::normalize($input);
+ } catch (NicknameException $e) {
+ $exception = $e;
+ }
+
+ if ($expected === false) {
+ if ($expectedException) {
+ if ($exception) {
+ $stuff = get_class($exception) . ': ' . $exception->getMessage();
+ } else {
+ $stuff = var_export($exception, true);
+ }
+ $this->assertTrue($exception && $exception instanceof $expectedException,
+ "invalid input '$input' expected to fail with $expectedException, " .
+ "got $stuff");
+ } else {
+ $this->assertTrue($normalized == false,
+ "invalid input '$input' expected to fail");
+ }
+ } else {
+ $msg = "normalized input nickname '$input' expected to normalize to '$expected', got ";
+ if ($exception) {
+ $msg .= get_class($exception) . ': ' . $exception->getMessage();
+ } else {
+ $msg .= "'$normalized'";
+ }
+ $this->assertEquals($expected, $normalized, $msg);
+ }
+ }
+
+ /**
+ * Test on the regex matching used in common_find_mentions
+ * (testing on the full notice rendering is difficult as it needs
+ * to be able to pull from global state)
+ *
+ * @dataProvider provider
+ * @param $input
+ * @param $expected
+ * @param null $expectedException
+ * @throws NicknameBlacklistedException
+ * @throws NicknameEmptyException
+ * @throws NicknameException
+ * @throws NicknameInvalidException
+ * @throws NicknamePathCollisionException
+ * @throws NicknameTakenException
+ * @throws NicknameTooLongException
+ */
+ public function testAtReply($input, $expected, $expectedException = null)
+ {
+ if ($expected == false) {
+ // nothing to do
+ } else {
+ $text = "@{$input} awesome! :)";
+ $matches = common_find_mentions_raw($text);
+ $this->assertEquals(1, count($matches));
+ $this->assertEquals($expected, Nickname::normalize($matches[0][0]));
+ }
+ }
+
+ static public function provider()
+ {
+ return array(
+ array('evan', 'evan'),
+
+ // Case and underscore variants
+ array('Evan', 'evan'),
+ array('EVAN', 'evan'),
+ array('ev_an', 'evan'),
+ array('E__V_an', 'evan'),
+ array('evan1', 'evan1'),
+ array('evan_1', 'evan1'),
+ array('0x20', '0x20'),
+ array('1234', '1234'), // should this be allowed though? :)
+ array('12__34', '1234'),
+
+ // Some (currently) invalid chars...
+ array('^#@&^#@', false, 'NicknameInvalidException'), // all invalid :D
+ array('ev.an', false, 'NicknameInvalidException'),
+ array('ev/an', false, 'NicknameInvalidException'),
+ array('ev an', false, 'NicknameInvalidException'),
+ array('ev-an', false, 'NicknameInvalidException'),
+
+ // Non-ASCII letters; currently not allowed, in future
+ // we'll add them at least with conversion to ASCII.
+ // Not much use until we have storage of display names,
+ // though.
+ array('évan', false, 'NicknameInvalidException'), // so far...
+ array('Évan', false, 'NicknameInvalidException'), // so far...
+
+ // Length checks
+ array('', false, 'NicknameEmptyException'),
+ array('___', false, 'NicknameEmptyException'),
+ array('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'), // 64 chars
+ array('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee_', false, 'NicknameTooLongException'), // the _ is too long...
+ array('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', false, 'NicknameTooLongException'), // 65 chars -- too long
+ );
+ }
+}
diff --git a/tests/Core/TagURITest.php b/tests/Core/TagURITest.php
new file mode 100644
index 0000000000..07343a35fa
--- /dev/null
+++ b/tests/Core/TagURITest.php
@@ -0,0 +1,59 @@
+.
+
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
+}
+
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+$config['site']['server'] = 'example.net';
+$config['site']['path'] = '/apps/statusnet';
+
+final class TagURITest extends TestCase
+{
+ /**
+ * @dataProvider provider
+ * @param $format
+ * @param $args
+ * @param $uri
+ */
+ public function testProduction($format, $args, $uri)
+ {
+ $minted = call_user_func_array(array('TagURI', 'mint'),
+ array_merge(array($format), $args));
+
+ $this->assertEquals($uri, $minted);
+ }
+
+ static public function provider()
+ {
+ return array(array('favorite:%d:%d',
+ array(1, 3),
+ 'tag:example.net,' . date('Y-m-d') . ':apps:statusnet:favorite:1:3'));
+ }
+}
+
diff --git a/tests/Core/URLDetectionTest.php b/tests/Core/URLDetectionTest.php
new file mode 100644
index 0000000000..e4adce5ab3
--- /dev/null
+++ b/tests/Core/URLDetectionTest.php
@@ -0,0 +1,377 @@
+.
+
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
+}
+
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class URLDetectionTest extends TestCase
+{
+ /**
+ * @dataProvider provider
+ * @param $content
+ * @param $expected
+ */
+ public function testProduction($content, $expected)
+ {
+ $rendered = common_render_text($content);
+ // hack!
+ $rendered = preg_replace('/id="attachment-\d+"/', 'id="attachment-XXX"', $rendered);
+ $this->assertEquals($expected, $rendered);
+ }
+
+ /**
+ * @dataProvider linkifyProvider
+ * @param $content
+ * @param $expected
+ * @param $config
+ */
+ public function testLinkifyProduction($content, $expected, $config)
+ {
+ $rendered = common_render_text($content);
+ // hack!
+ $rendered = preg_replace('/id="attachment-\d+"/', 'id="attachment-XXX"', $rendered);
+ if (common_config('linkify', $config)) {
+ $this->assertEquals($expected, $rendered);
+ } else {
+ $content = common_remove_unicode_formatting(nl2br(htmlspecialchars($content)));
+ $this->assertEquals($content, $rendered);
+ }
+ }
+
+ static public function provider()
+ {
+ return array(
+ array('not a link :: no way',
+ 'not a link :: no way'),
+ array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
+ 'link http://www.somesite.com/xyz/35637563@N00/52803365/ link'),
+ array('http://127.0.0.1',
+ 'http://127.0.0.1'),
+ array('http://[::1]:99/test.php',
+ 'http://[::1]:99/test.php'),
+ array('http://::1/test.php',
+ 'http://::1/test.php'),
+ array('http://::1',
+ 'http://::1'),
+ array('http://127.0.0.1',
+ 'http://127.0.0.1'),
+ array('http://example.com',
+ 'http://example.com'),
+ array('http://example.com.',
+ 'http://example.com.'),
+ array('/var/lib/example.so',
+ '/var/lib/example.so'),
+ array('example',
+ 'example'),
+ array('mailto:user@example.com',
+ 'mailto:user@example.com'),
+ array('mailto:user@example.com?subject=test',
+ 'mailto:user@example.com?subject=test'),
+ array('xmpp:user@example.com',
+ 'xmpp:user@example.com'),
+ array('#example',
+ '#example'),
+ array('#example.com',
+ '#example.com'),
+ array('#.net',
+ '#.net'),
+ array('http://example',
+ 'http://example'),
+ array('http://3xampl3',
+ 'http://3xampl3'),
+ array('http://example/',
+ 'http://example/'),
+ array('http://example/path',
+ 'http://example/path'),
+ array('http://example.com',
+ 'http://example.com'),
+ array('https://example.com',
+ 'https://example.com'),
+ array('ftp://example.com',
+ 'ftp://example.com'),
+ array('ftps://example.com',
+ 'ftps://example.com'),
+ array('http://user@example.com',
+ 'http://user@example.com'),
+ array('http://user:pass@example.com',
+ 'http://user:pass@example.com'),
+ array('http://example.com:8080',
+ 'http://example.com:8080'),
+ array('http://example.com:8080/test.php',
+ 'http://example.com:8080/test.php'),
+ array('http://www.example.com',
+ 'http://www.example.com'),
+ array('http://example.com/',
+ 'http://example.com/'),
+ array('http://example.com/path',
+ 'http://example.com/path'),
+ array('http://example.com/path.html',
+ 'http://example.com/path.html'),
+ array('http://example.com/path.html#fragment',
+ 'http://example.com/path.html#fragment'),
+ array('http://example.com/path.php?foo=bar&bar=foo',
+ 'http://example.com/path.php?foo=bar&bar=foo'),
+ array('http://example.com.',
+ 'http://example.com.'),
+ array('http://müllärör.de',
+ 'http://müllärör.de'),
+ array('http://ﺱﺲﺷ.com',
+ 'http://ﺱﺲﺷ.com'),
+ array('http://сделаткартинки.com',
+ 'http://сделаткартинки.com'),
+ array('http://tūdaliņ.lv',
+ 'http://tūdaliņ.lv'),
+ array('http://brændendekærlighed.com',
+ 'http://brændendekærlighed.com'),
+ array('http://あーるいん.com',
+ 'http://あーるいん.com'),
+ array('http://예비교사.com',
+ 'http://예비교사.com'),
+ array('http://example.com.',
+ 'http://example.com.'),
+ array('http://example.com?',
+ 'http://example.com?'),
+ array('http://example.com!',
+ 'http://example.com!'),
+ array('http://example.com,',
+ 'http://example.com,'),
+ array('http://example.com;',
+ 'http://example.com;'),
+ array('http://example.com:',
+ 'http://example.com:'),
+ array('\'http://example.com\'',
+ '\'http://example.com\''),
+ array('"http://example.com"',
+ '"http://example.com"'),
+ array('"http://example.com/"',
+ '"http://example.com/"'),
+ array('http://example.com',
+ 'http://example.com'),
+ array('(http://example.com)',
+ '(http://example.com)'),
+ array('[http://example.com]',
+ '[http://example.com]'),
+ array('',
+ '<http://example.com>'),
+ array('http://example.com/path/(foo)/bar',
+ 'http://example.com/path/(foo)/bar'),
+ array('http://example.com/path/[foo]/bar',
+ 'http://example.com/path/[foo]/bar'),
+ array('http://example.com/path/foo/(bar)',
+ 'http://example.com/path/foo/(bar)'),
+ //Not a valid url - urls cannot contain unencoded square brackets
+ array('http://example.com/path/foo/[bar]',
+ 'http://example.com/path/foo/[bar]'),
+ array('Hey, check out my cool site http://example.com okay?',
+ 'Hey, check out my cool site http://example.com okay?'),
+ array('What about parens (e.g. http://example.com/path/foo/(bar))?',
+ 'What about parens (e.g. http://example.com/path/foo/(bar))?'),
+ array('What about parens (e.g. http://example.com/path/foo/(bar)?',
+ 'What about parens (e.g. http://example.com/path/foo/(bar)?'),
+ array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
+ 'What about parens (e.g. http://example.com/path/foo/(bar).)?'),
+ //Not a valid url - urls cannot contain unencoded commas
+ array('What about parens (e.g. http://example.com/path/(foo,bar)?',
+ 'What about parens (e.g. http://example.com/path/(foo,bar)?'),
+ array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
+ 'Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?'),
+ array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
+ 'Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?'),
+ array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
+ 'Unbalanced too (e.g. http://example.com/path/foo/((((bar)?'),
+ array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
+ 'Unbalanced too (e.g. http://example.com/path/foo/(bar))))?'),
+ array('file.ext',
+ 'file.ext'),
+ array('file.html',
+ 'file.html'),
+ array('file.php',
+ 'file.php'),
+
+ // scheme-less HTTP URLs with @ in the path: http://status.net/open-source/issues/2248
+ array('http://flickr.com/photos/34807140@N05/3838905434',
+ 'http://flickr.com/photos/34807140@N05/3838905434'),
+ );
+ }
+
+ static public function linkifyProvider()
+ {
+ return array(
+ //bare ip addresses are no longer supported
+ array('127.0.0.1',
+ '127.0.0.1',
+ 'bare_ipv4'),
+ array('127.0.0.1:99',
+ '127.0.0.1:99',
+ 'bare_ipv4'),
+ array('127.0.0.1/Name:test.php',
+ '127.0.0.1/Name:test.php',
+ 'bare_ipv4'),
+ array('127.0.0.1/~test',
+ '127.0.0.1/~test',
+ 'bare_ipv4'),
+ array('127.0.0.1/+test',
+ '127.0.0.1/+test',
+ 'bare_ipv4'),
+ array('127.0.0.1/$test',
+ '127.0.0.1/$test',
+ 'bare_ipv4'),
+ array('127.0.0.1/\'test',
+ '127.0.0.1/\'test',
+ 'bare_ipv4'),
+ array('127.0.0.1/"test',
+ '127.0.0.1/"test',
+ 'bare_ipv4'),
+ array('127.0.0.1/test"test',
+ '127.0.0.1/test"test',
+ 'bare_ipv4'),
+ array('127.0.0.1/-test',
+ '127.0.0.1/-test',
+ 'bare_ipv4'),
+ array('127.0.0.1/_test',
+ '127.0.0.1/_test',
+ 'bare_ipv4'),
+ array('127.0.0.1/!test',
+ '127.0.0.1/!test',
+ 'bare_ipv4'),
+ array('127.0.0.1/*test',
+ '127.0.0.1/*test',
+ 'bare_ipv4'),
+ array('127.0.0.1/test%20stuff',
+ '127.0.0.1/test%20stuff',
+ 'bare_ipv4'),
+ array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
+ '2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
+ 'bare_ipv6'),
+ array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
+ '[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
+ 'bare_ipv6'),
+ array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
+ '2001:4978:1b5:0:21d:e0ff:fe66:59ab',
+ 'bare_ipv6'),
+ array('example.com',
+ 'example.com',
+ 'bare_domains'),
+ array('flickr.com/photos/34807140@N05/3838905434',
+ 'flickr.com/photos/34807140@N05/3838905434',
+ 'bare_domains'),
+ array('What about parens (e.g. example.com/path/foo/(bar))?',
+ 'What about parens (e.g. example.com/path/foo/(bar))?',
+ 'bare_domains'),
+ array('What about parens (e.g. example.com/path/foo/(bar)?',
+ 'What about parens (e.g. example.com/path/foo/(bar)?',
+ 'bare_domains'),
+ array('What about parens (e.g. example.com/path/foo/(bar).)?',
+ 'What about parens (e.g. example.com/path/foo/(bar).?',
+ 'bare_domains'),
+ array('What about parens (e.g. example.com/path/(foo,bar)?',
+ 'What about parens (e.g. example.com/path/(foo,bar)?',
+ 'bare_domains'),
+ array('example.com',
+ 'example.com',
+ 'bare_domains'),
+ array('example.org',
+ 'example.org',
+ 'bare_domains'),
+ array('example.co.uk',
+ 'example.co.uk',
+ 'bare_domains'),
+ array('www.example.co.uk',
+ 'www.example.co.uk',
+ 'bare_domains'),
+ array('farm1.images.example.co.uk',
+ 'farm1.images.example.co.uk',
+ 'bare_domains'),
+ array('example.museum',
+ 'example.museum',
+ 'bare_domains'),
+ array('example.travel',
+ 'example.travel',
+ 'bare_domains'),
+ array('example.com.',
+ 'example.com.',
+ 'bare_domains'),
+ array('example.com?',
+ 'example.com?',
+ 'bare_domains'),
+ array('example.com!',
+ 'example.com!',
+ 'bare_domains'),
+ array('example.com,',
+ 'example.com,',
+ 'bare_domains'),
+ array('example.com;',
+ 'example.com;',
+ 'bare_domains'),
+ array('example.com:',
+ 'example.com:',
+ 'bare_domains'),
+ array('\'example.com\'',
+ '\'example.com\'',
+ 'bare_domains'),
+ array('"example.com"',
+ '"example.com"',
+ 'bare_domains'),
+ array('example.com',
+ 'example.com',
+ 'bare_domains'),
+ array('(example.com)',
+ '(example.com)',
+ 'bare_domains'),
+ array('[example.com]',
+ '[example.com]',
+ 'bare_domains'),
+ array('',
+ '<example.com>',
+ 'bare_domains'),
+ array('Hey, check out my cool site example.com okay?',
+ 'Hey, check out my cool site example.com okay?',
+ 'bare_domains'),
+ array('Hey, check out my cool site example.com.I made it.',
+ 'Hey, check out my cool site example.com.I made it.',
+ 'bare_domains'),
+ array('Hey, check out my cool site example.com.Funny thing...',
+ 'Hey, check out my cool site example.com.Funny thing...',
+ 'bare_domains'),
+ array('Hey, check out my cool site example.com.You will love it.',
+ 'Hey, check out my cool site example.com.You will love it.',
+ 'bare_domains'),
+ array('example.com:8080/test.php',
+ 'example.com:8080/test.php',
+ 'bare_domains'),
+ array('user_name+other@example.com',
+ 'user_name+other@example.com',
+ 'bare_domains'),
+ array('user@example.com',
+ 'user@example.com',
+ 'bare_domains'),
+ );
+ }
+}
+
diff --git a/tests/Core/UUIDTest.php b/tests/Core/UUIDTest.php
new file mode 100644
index 0000000000..50e9257a07
--- /dev/null
+++ b/tests/Core/UUIDTest.php
@@ -0,0 +1,58 @@
+.
+
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
+}
+
+use PHPUnit\Framework\TestCase;
+use UUID;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class UUIDTest extends TestCase
+{
+ public function testGenerate()
+ {
+ $result = UUID::gen();
+ $this->assertRegExp('/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/',
+ $result);
+ // Check version number
+ $this->assertEquals(0x4000, hexdec(substr($result, 14, 4)) & 0xF000);
+ $this->assertEquals(0x8000, hexdec(substr($result, 19, 4)) & 0xC000);
+ }
+
+ public function testUnique()
+ {
+ $reps = 100;
+ $ids = array();
+
+ for ($i = 0; $i < $reps; $i++) {
+ $ids[] = UUID::gen();
+ }
+
+ $this->assertEquals(count($ids), count(array_unique($ids)), "UUIDs must be unique");
+ }
+}
+
diff --git a/tests/UserFeedParseTest.php b/tests/Core/UserFeedParseTest.php
similarity index 76%
rename from tests/UserFeedParseTest.php
rename to tests/Core/UserFeedParseTest.php
index b68783bb03..f2685469d9 100644
--- a/tests/UserFeedParseTest.php
+++ b/tests/Core/UserFeedParseTest.php
@@ -1,22 +1,45 @@
.
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
}
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('GNUSOCIAL', true);
-define('STATUSNET', true); // compatibility
+use Activity;
+use ActivityObject;
+use DOMDocument;
+use PHPUnit\Framework\TestCase;
require_once INSTALLDIR . '/lib/common.php';
-class UserFeedParseTests extends PHPUnit_Framework_TestCase
+final class UserFeedParseTests extends TestCase
{
public function testFeed1()
{
global $_testfeed1;
- $dom = DOMDocument::loadXML($_testfeed1);
+ $dom = new DOMDocument();
+ $dom->loadXML($_testfeed1);
$this->assertFalse(empty($dom));
$entries = $dom->getElementsByTagName('entry');
@@ -40,18 +63,18 @@ class UserFeedParseTests extends PHPUnit_Framework_TestCase
$avatars = $act1->actor->avatarLinks;
$this->assertEquals(
- $avatars[0]->url,
- 'http://localhost/statusnet/theme/default/default-avatar-profile.png'
+ $avatars[0]->url,
+ 'http://localhost/statusnet/theme/default/default-avatar-profile.png'
);
$this->assertEquals(
- $avatars[1]->url,
- 'http://localhost/statusnet/theme/default/default-avatar-stream.png'
+ $avatars[1]->url,
+ 'http://localhost/statusnet/theme/default/default-avatar-stream.png'
);
$this->assertEquals(
- $avatars[2]->url,
- 'http://localhost/statusnet/theme/default/default-avatar-mini.png'
+ $avatars[2]->url,
+ 'http://localhost/statusnet/theme/default/default-avatar-mini.png'
);
$this->assertEquals($act1->actor->displayName, 'Zach Copley');
diff --git a/tests/UserRightsTest.php b/tests/Core/UserRightsTest.php
similarity index 52%
rename from tests/UserRightsTest.php
rename to tests/Core/UserRightsTest.php
index bd9124a91d..42af9ba683 100644
--- a/tests/UserRightsTest.php
+++ b/tests/Core/UserRightsTest.php
@@ -1,17 +1,38 @@
.
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
}
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('GNUSOCIAL', true);
-define('STATUSNET', true); // compatibility
+use Exception;
+use PHPUnit\Framework\TestCase;
+use User;
require_once INSTALLDIR . '/lib/common.php';
-class UserRightsTest extends PHPUnit_Framework_TestCase
+final class UserRightsTest extends TestCase
{
protected $user = null;
@@ -47,12 +68,12 @@ class UserRightsTest extends PHPUnit_Framework_TestCase
function standardRoles()
{
return array(array('admin'),
- array('moderator'));
+ array('moderator'));
}
/**
* @dataProvider standardRoles
- *
+ * @param $role
*/
function testUngrantedRole($role)
@@ -62,7 +83,7 @@ class UserRightsTest extends PHPUnit_Framework_TestCase
/**
* @dataProvider standardRoles
- *
+ * @param $role
*/
function testGrantedRole($role)
diff --git a/tests/XmppValidateTest.php b/tests/Core/XmppValidateTest.php
similarity index 72%
rename from tests/XmppValidateTest.php
rename to tests/Core/XmppValidateTest.php
index f3377390aa..f751eb092f 100644
--- a/tests/XmppValidateTest.php
+++ b/tests/Core/XmppValidateTest.php
@@ -1,55 +1,82 @@
.
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
}
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('GNUSOCIAL', true);
-define('STATUSNET', true); // compatibility
-
-mb_internal_encoding('UTF-8'); // @fixme this probably belongs in common.php?
+use GNUsocial;
+use PHPUnit\Framework\TestCase;
+use XmppPlugin;
require_once INSTALLDIR . '/lib/common.php';
+
require_once INSTALLDIR . '/plugins/Xmpp/XmppPlugin.php';
-class XmppValidateTest extends PHPUnit_Framework_TestCase
+final class XmppValidateTest extends TestCase
{
- public function setUp()
- {
- if(!array_key_exists('Xmpp', GNUsocial::getActivePlugins())){
- $this->markTestSkipped('XmppPlugin is not enabled.');
- }
- }
+ public function setUp()
+ {
+ if (!array_key_exists('Xmpp', GNUsocial::getActivePlugins())) {
+ $this->markTestSkipped('XmppPlugin is not enabled.');
+ }
+ }
+
/**
* @dataProvider validationCases
- *
+ * @param $jid
+ * @param $validFull
+ * @param $validBase
*/
public function testValidate($jid, $validFull, $validBase)
{
- $xmpp = new TestXmppPlugin();
- $this->assertEquals($validFull || $validBase, $xmpp->validate($jid));
+ $xmpp = new TestXmppPlugin();
+ $this->assertEquals($validFull || $validBase, $xmpp->validate($jid));
$this->assertEquals($validFull, $xmpp->validateFullJid($jid), "validating as full or base JID");
$this->assertEquals($validBase, $xmpp->validateBaseJid($jid), "validating as base JID only");
}
/**
* @dataProvider normalizationCases
- *
+ * @param $jid
+ * @param $expected
*/
public function testNormalize($jid, $expected)
{
- $xmpp = new XmppPlugin();
+ $xmpp = new XmppPlugin();
$this->assertEquals($expected, $xmpp->normalize($jid));
}
/**
* @dataProvider domainCheckCases()
+ * @param $domain
+ * @param $expected
+ * @param $note
*/
public function testDomainCheck($domain, $expected, $note)
{
- $xmpp = new TestXmppPlugin();
+ $xmpp = new TestXmppPlugin();
$this->assertEquals($expected, $xmpp->checkDomain($domain), $note);
}
@@ -68,7 +95,7 @@ class XmppValidateTest extends PHPUnit_Framework_TestCase
array('example.com', true, true),
array('example.com/resource', true, false),
array('jabchat', true, true),
-
+
array("$long1023@$long1023/$long1023", true, false), // max 1023 "bytes" per portion per spec. Do they really mean bytes though?
array("$long1024@$long1023/$long1023", false, false),
array("$long1023@$long1024/$long1023", false, false),
@@ -125,7 +152,7 @@ class XmppValidateTest extends PHPUnit_Framework_TestCase
//array("foo@example.com/٭simplexe٭", false, false)
);
}
-
+
static public function normalizationCases()
{
return array(
@@ -153,19 +180,20 @@ class XmppValidateTest extends PHPUnit_Framework_TestCase
}
-class TestXmppPlugin extends XmppPlugin {
- public function checkDomain($domain)
- {
- return parent::checkDomain($domain);
- }
-
- public function validateBaseJid($jid, $check_domain=false)
- {
- return parent::validateBaseJid($jid, $check_domain);
- }
-
- public function validateFullJid($jid, $check_domain=false)
- {
- return parent::validateFullJid($jid, $check_domain);
- }
-}
\ No newline at end of file
+class TestXmppPlugin extends XmppPlugin
+{
+ public function checkDomain($domain)
+ {
+ return parent::checkDomain($domain);
+ }
+
+ public function validateBaseJid($jid, $check_domain = false)
+ {
+ return parent::validateBaseJid($jid, $check_domain);
+ }
+
+ public function validateFullJid($jid, $check_domain = false)
+ {
+ return parent::validateFullJid($jid, $check_domain);
+ }
+}
diff --git a/tests/CurryTest.php b/tests/CurryTest.php
deleted file mode 100644
index 2722a54fc5..0000000000
--- a/tests/CurryTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-assertEquals($expected, $result);
- }
-
- static public function provider()
- {
- $obj = new CurryTestHelperObj('oldval');
- return array(array(array('CurryTest', 'callback'),
- array('curried'),
- array('called'),
- 'called|curried'),
- array(array('CurryTest', 'callback'),
- array('curried1', 'curried2'),
- array('called1', 'called2'),
- 'called1|called2|curried1|curried2'),
- array(array('CurryTest', 'callbackObj'),
- array($obj),
- array('newval1'),
- 'oldval|newval1'),
- // Confirm object identity is retained...
- array(array('CurryTest', 'callbackObj'),
- array($obj),
- array('newval2'),
- 'newval1|newval2'));
- }
-
- static function callback()
- {
- $args = func_get_args();
- return implode("|", $args);
- }
-
- static function callbackObj($val, $obj)
- {
- $old = $obj->val;
- $obj->val = $val;
- return "$old|$val";
- }
-}
-
-class CurryTestHelperObj
-{
- public $val='';
-
- function __construct($val)
- {
- $this->val = $val;
- }
-}
diff --git a/tests/HashTagDetectionTests.php b/tests/HashTagDetectionTests.php
deleted file mode 100644
index 1fbc98983d..0000000000
--- a/tests/HashTagDetectionTests.php
+++ /dev/null
@@ -1,63 +0,0 @@
-assertEquals($expected, $rendered);
- }
-
- static public function provider()
- {
- return array(
- array('hello',
- 'hello'),
- array('#hello people',
- '#hello people'),
- array('"#hello" people',
- '"#hello" people'),
- array('say "#hello" people',
- 'say "#hello" people'),
- array('say (#hello) people',
- 'say (#hello) people'),
- array('say [#hello] people',
- 'say [#hello] people'),
- array('say {#hello} people',
- 'say {#hello} people'),
- array('say \'#hello\' people',
- 'say \'#hello\' people'),
-
- // Unicode legit letters
- array('#éclair yummy',
- '#éclair yummy'),
- array('#维基百科 zh.wikipedia!',
- '#维基百科 zh.wikipedia!'),
- array('#Россия russia',
- '#Россия russia'),
-
- // Unicode punctuators -- the ideographic "," separates the tag, just as "," does
- array('#维基百科,zh.wikipedia!',
- '#维基百科,zh.wikipedia!'),
- array('#维基百科,zh.wikipedia!',
- '#维基百科,zh.wikipedia!'),
-
- );
- }
-}
-
diff --git a/tests/LocationTest.php b/tests/LocationTest.php
deleted file mode 100644
index f7df271b53..0000000000
--- a/tests/LocationTest.php
+++ /dev/null
@@ -1,89 +0,0 @@
-assertEquals($result, $location);
- }
-
- static public function locationNames()
- {
- return array(array('Montreal', 'en', null),
- array('San Francisco, CA', 'en', null),
- array('Paris, France', 'en', null),
- array('Paris, Texas', 'en', null));
- }
-
- /**
- * @dataProvider locationIds
- */
-
- public function testLocationFromId($id, $ns, $language, $location)
- {
- $result = Location::fromId($id, $ns, $language);
- $this->assertEquals($result, $location);
- }
-
- static public function locationIds()
- {
- return array(array(6077243, GeonamesPlugin::LOCATION_NS, 'en', null),
- array(5391959, GeonamesPlugin::LOCATION_NS, 'en', null));
- }
-
- /**
- * @dataProvider locationLatLons
- */
-
- public function testLocationFromLatLon($lat, $lon, $language, $location)
- {
- $result = Location::fromLatLon($lat, $lon, $language);
- $this->assertEquals($location, $result->location_id);
- }
-
- static public function locationLatLons()
- {
- return array(array(37.77493, -122.41942, 'en', null),
- array(45.509, -73.588, 'en', null));
- }
-
- /**
- * @dataProvider nameOfLocation
- */
-
- public function testLocationGetName($location, $language, $name)
- {
- $result = empty($location)?null:$location->getName($language);
- $this->assertEquals($name, $result);
- }
-
- static public function nameOfLocation()
- {
- $loc = Location::fromName('Montreal', 'en');
- return array(array($loc, 'en', null), //'Montreal'),
- array($loc, 'fr', null));//'Montréal'));
- }
-}
-
diff --git a/tests/MediaFileTest.php b/tests/Media/MediaFileTest.php
similarity index 68%
rename from tests/MediaFileTest.php
rename to tests/Media/MediaFileTest.php
index 1e4a3c9dbb..cd28941896 100644
--- a/tests/MediaFileTest.php
+++ b/tests/Media/MediaFileTest.php
@@ -1,17 +1,40 @@
.
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
}
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('GNUSOCIAL', true);
-define('STATUSNET', true); // compatibility
+use ClientException;
+use Exception;
+use MediaFile;
+use PHPUnit\Framework\TestCase;
+use ServerException;
require_once INSTALLDIR . '/lib/common.php';
-class MediaFileTest extends PHPUnit_Framework_TestCase
+final class MediaFileTest extends TestCase
{
public function setup()
@@ -27,7 +50,10 @@ class MediaFileTest extends PHPUnit_Framework_TestCase
/**
* @dataProvider fileTypeCases
- *
+ * @param $filename
+ * @param $expectedType
+ * @throws ClientException
+ * @throws ServerException
*/
public function testMimeType($filename, $expectedType)
{
@@ -41,7 +67,10 @@ class MediaFileTest extends PHPUnit_Framework_TestCase
/**
* @dataProvider fileTypeCases
- *
+ * @param $filename
+ * @param $expectedType
+ * @throws ClientException
+ * @throws ServerException
*/
public function testUploadedMimeType($filename, $expectedType)
{
diff --git a/tests/sample-uploads/image.gif b/tests/Media/sample-uploads/image.gif
similarity index 100%
rename from tests/sample-uploads/image.gif
rename to tests/Media/sample-uploads/image.gif
diff --git a/tests/sample-uploads/image.jpeg b/tests/Media/sample-uploads/image.jpeg
similarity index 100%
rename from tests/sample-uploads/image.jpeg
rename to tests/Media/sample-uploads/image.jpeg
diff --git a/tests/sample-uploads/image.jpg b/tests/Media/sample-uploads/image.jpg
similarity index 100%
rename from tests/sample-uploads/image.jpg
rename to tests/Media/sample-uploads/image.jpg
diff --git a/tests/sample-uploads/image.png b/tests/Media/sample-uploads/image.png
similarity index 100%
rename from tests/sample-uploads/image.png
rename to tests/Media/sample-uploads/image.png
diff --git a/tests/sample-uploads/office.pdf b/tests/Media/sample-uploads/office.pdf
similarity index 100%
rename from tests/sample-uploads/office.pdf
rename to tests/Media/sample-uploads/office.pdf
diff --git a/tests/sample-uploads/presentation.odp b/tests/Media/sample-uploads/presentation.odp
similarity index 100%
rename from tests/sample-uploads/presentation.odp
rename to tests/Media/sample-uploads/presentation.odp
diff --git a/tests/sample-uploads/presentation.otp b/tests/Media/sample-uploads/presentation.otp
similarity index 100%
rename from tests/sample-uploads/presentation.otp
rename to tests/Media/sample-uploads/presentation.otp
diff --git a/tests/sample-uploads/presentation.pot b/tests/Media/sample-uploads/presentation.pot
similarity index 100%
rename from tests/sample-uploads/presentation.pot
rename to tests/Media/sample-uploads/presentation.pot
diff --git a/tests/sample-uploads/presentation.potm b/tests/Media/sample-uploads/presentation.potm
similarity index 100%
rename from tests/sample-uploads/presentation.potm
rename to tests/Media/sample-uploads/presentation.potm
diff --git a/tests/sample-uploads/presentation.ppt b/tests/Media/sample-uploads/presentation.ppt
similarity index 100%
rename from tests/sample-uploads/presentation.ppt
rename to tests/Media/sample-uploads/presentation.ppt
diff --git a/tests/sample-uploads/presentation.pptx b/tests/Media/sample-uploads/presentation.pptx
similarity index 100%
rename from tests/sample-uploads/presentation.pptx
rename to tests/Media/sample-uploads/presentation.pptx
diff --git a/tests/sample-uploads/spreadsheet.ods b/tests/Media/sample-uploads/spreadsheet.ods
similarity index 100%
rename from tests/sample-uploads/spreadsheet.ods
rename to tests/Media/sample-uploads/spreadsheet.ods
diff --git a/tests/sample-uploads/spreadsheet.ots b/tests/Media/sample-uploads/spreadsheet.ots
similarity index 100%
rename from tests/sample-uploads/spreadsheet.ots
rename to tests/Media/sample-uploads/spreadsheet.ots
diff --git a/tests/sample-uploads/spreadsheet.xls b/tests/Media/sample-uploads/spreadsheet.xls
similarity index 100%
rename from tests/sample-uploads/spreadsheet.xls
rename to tests/Media/sample-uploads/spreadsheet.xls
diff --git a/tests/sample-uploads/spreadsheet.xlsx b/tests/Media/sample-uploads/spreadsheet.xlsx
similarity index 100%
rename from tests/sample-uploads/spreadsheet.xlsx
rename to tests/Media/sample-uploads/spreadsheet.xlsx
diff --git a/tests/sample-uploads/spreadsheet.xlt b/tests/Media/sample-uploads/spreadsheet.xlt
similarity index 100%
rename from tests/sample-uploads/spreadsheet.xlt
rename to tests/Media/sample-uploads/spreadsheet.xlt
diff --git a/tests/sample-uploads/wordproc.doc b/tests/Media/sample-uploads/wordproc.doc
similarity index 100%
rename from tests/sample-uploads/wordproc.doc
rename to tests/Media/sample-uploads/wordproc.doc
diff --git a/tests/sample-uploads/wordproc.docx b/tests/Media/sample-uploads/wordproc.docx
similarity index 100%
rename from tests/sample-uploads/wordproc.docx
rename to tests/Media/sample-uploads/wordproc.docx
diff --git a/tests/sample-uploads/wordproc.odt b/tests/Media/sample-uploads/wordproc.odt
similarity index 100%
rename from tests/sample-uploads/wordproc.odt
rename to tests/Media/sample-uploads/wordproc.odt
diff --git a/tests/sample-uploads/wordproc.ott b/tests/Media/sample-uploads/wordproc.ott
similarity index 100%
rename from tests/sample-uploads/wordproc.ott
rename to tests/Media/sample-uploads/wordproc.ott
diff --git a/tests/sample-uploads/wordproc.rtf b/tests/Media/sample-uploads/wordproc.rtf
similarity index 100%
rename from tests/sample-uploads/wordproc.rtf
rename to tests/Media/sample-uploads/wordproc.rtf
diff --git a/tests/NicknameTest.php b/tests/NicknameTest.php
deleted file mode 100644
index 2841398a65..0000000000
--- a/tests/NicknameTest.php
+++ /dev/null
@@ -1,116 +0,0 @@
-getMessage();
- } else {
- $stuff = var_export($exception, true);
- }
- $this->assertTrue($exception && $exception instanceof $expectedException,
- "invalid input '$input' expected to fail with $expectedException, " .
- "got $stuff");
- } else {
- $this->assertTrue($normalized == false,
- "invalid input '$input' expected to fail");
- }
- } else {
- $msg = "normalized input nickname '$input' expected to normalize to '$expected', got ";
- if ($exception) {
- $msg .= get_class($exception) . ': ' . $exception->getMessage();
- } else {
- $msg .= "'$normalized'";
- }
- $this->assertEquals($expected, $normalized, $msg);
- }
- }
-
- /**
- * Test on the regex matching used in common_find_mentions
- * (testing on the full notice rendering is difficult as it needs
- * to be able to pull from global state)
- *
- * @dataProvider provider
- */
- public function testAtReply($input, $expected, $expectedException=null)
- {
- if ($expected == false) {
- // nothing to do
- } else {
- $text = "@{$input} awesome! :)";
- $matches = common_find_mentions_raw($text);
- $this->assertEquals(1, count($matches));
- $this->assertEquals($expected, Nickname::normalize($matches[0][0]));
- }
- }
-
- static public function provider()
- {
- return array(
- array('evan', 'evan'),
-
- // Case and underscore variants
- array('Evan', 'evan'),
- array('EVAN', 'evan'),
- array('ev_an', 'evan'),
- array('E__V_an', 'evan'),
- array('evan1', 'evan1'),
- array('evan_1', 'evan1'),
- array('0x20', '0x20'),
- array('1234', '1234'), // should this be allowed though? :)
- array('12__34', '1234'),
-
- // Some (currently) invalid chars...
- array('^#@&^#@', false, 'NicknameInvalidException'), // all invalid :D
- array('ev.an', false, 'NicknameInvalidException'),
- array('ev/an', false, 'NicknameInvalidException'),
- array('ev an', false, 'NicknameInvalidException'),
- array('ev-an', false, 'NicknameInvalidException'),
-
- // Non-ASCII letters; currently not allowed, in future
- // we'll add them at least with conversion to ASCII.
- // Not much use until we have storage of display names,
- // though.
- array('évan', false, 'NicknameInvalidException'), // so far...
- array('Évan', false, 'NicknameInvalidException'), // so far...
-
- // Length checks
- array('', false, 'NicknameEmptyException'),
- array('___', false, 'NicknameEmptyException'),
- array('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'), // 64 chars
- array('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee_', false, 'NicknameTooLongException'), // the _ is too long...
- array('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', false, 'NicknameTooLongException'), // 65 chars -- too long
- );
- }
-}
diff --git a/tests/TagURITest.php b/tests/TagURITest.php
deleted file mode 100644
index ccc80b8064..0000000000
--- a/tests/TagURITest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-assertEquals($uri, $minted);
- }
-
- static public function provider()
- {
- return array(array('favorite:%d:%d',
- array(1, 3),
- 'tag:example.net,'.date('Y-m-d').':apps:statusnet:favorite:1:3'));
- }
-}
-
diff --git a/tests/URLDetectionTest.php b/tests/URLDetectionTest.php
deleted file mode 100644
index 6d0771d101..0000000000
--- a/tests/URLDetectionTest.php
+++ /dev/null
@@ -1,355 +0,0 @@
-assertEquals($expected, $rendered);
- }
-
- /**
- * @dataProvider linkifyProvider
- *
- */
- public function testLinkifyProduction($content, $expected, $config)
- {
- $rendered = common_render_text($content);
- // hack!
- $rendered = preg_replace('/id="attachment-\d+"/', 'id="attachment-XXX"', $rendered);
- if(common_config('linkify', $config)){
- $this->assertEquals($expected, $rendered);
- } else {
- $content = common_remove_unicode_formatting(nl2br(htmlspecialchars($content)));
- $this->assertEquals($content, $rendered);
- }
- }
-
- static public function provider()
- {
- return array(
- array('not a link :: no way',
- 'not a link :: no way'),
- array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
- 'link http://www.somesite.com/xyz/35637563@N00/52803365/ link'),
- array('http://127.0.0.1',
- 'http://127.0.0.1'),
- array('http://[::1]:99/test.php',
- 'http://[::1]:99/test.php'),
- array('http://::1/test.php',
- 'http://::1/test.php'),
- array('http://::1',
- 'http://::1'),
- array('http://127.0.0.1',
- 'http://127.0.0.1'),
- array('http://example.com',
- 'http://example.com'),
- array('http://example.com.',
- 'http://example.com.'),
- array('/var/lib/example.so',
- '/var/lib/example.so'),
- array('example',
- 'example'),
- array('mailto:user@example.com',
- 'mailto:user@example.com'),
- array('mailto:user@example.com?subject=test',
- 'mailto:user@example.com?subject=test'),
- array('xmpp:user@example.com',
- 'xmpp:user@example.com'),
- array('#example',
- '#example'),
- array('#example.com',
- '#example.com'),
- array('#.net',
- '#.net'),
- array('http://example',
- 'http://example'),
- array('http://3xampl3',
- 'http://3xampl3'),
- array('http://example/',
- 'http://example/'),
- array('http://example/path',
- 'http://example/path'),
- array('http://example.com',
- 'http://example.com'),
- array('https://example.com',
- 'https://example.com'),
- array('ftp://example.com',
- 'ftp://example.com'),
- array('ftps://example.com',
- 'ftps://example.com'),
- array('http://user@example.com',
- 'http://user@example.com'),
- array('http://user:pass@example.com',
- 'http://user:pass@example.com'),
- array('http://example.com:8080',
- 'http://example.com:8080'),
- array('http://example.com:8080/test.php',
- 'http://example.com:8080/test.php'),
- array('http://www.example.com',
- 'http://www.example.com'),
- array('http://example.com/',
- 'http://example.com/'),
- array('http://example.com/path',
- 'http://example.com/path'),
- array('http://example.com/path.html',
- 'http://example.com/path.html'),
- array('http://example.com/path.html#fragment',
- 'http://example.com/path.html#fragment'),
- array('http://example.com/path.php?foo=bar&bar=foo',
- 'http://example.com/path.php?foo=bar&bar=foo'),
- array('http://example.com.',
- 'http://example.com.'),
- array('http://müllärör.de',
- 'http://müllärör.de'),
- array('http://ﺱﺲﺷ.com',
- 'http://ﺱﺲﺷ.com'),
- array('http://сделаткартинки.com',
- 'http://сделаткартинки.com'),
- array('http://tūdaliņ.lv',
- 'http://tūdaliņ.lv'),
- array('http://brændendekærlighed.com',
- 'http://brændendekærlighed.com'),
- array('http://あーるいん.com',
- 'http://あーるいん.com'),
- array('http://예비교사.com',
- 'http://예비교사.com'),
- array('http://example.com.',
- 'http://example.com.'),
- array('http://example.com?',
- 'http://example.com?'),
- array('http://example.com!',
- 'http://example.com!'),
- array('http://example.com,',
- 'http://example.com,'),
- array('http://example.com;',
- 'http://example.com;'),
- array('http://example.com:',
- 'http://example.com:'),
- array('\'http://example.com\'',
- '\'http://example.com\''),
- array('"http://example.com"',
- '"http://example.com"'),
- array('"http://example.com/"',
- '"http://example.com/"'),
- array('http://example.com',
- 'http://example.com'),
- array('(http://example.com)',
- '(http://example.com)'),
- array('[http://example.com]',
- '[http://example.com]'),
- array('',
- '<http://example.com>'),
- array('http://example.com/path/(foo)/bar',
- 'http://example.com/path/(foo)/bar'),
- array('http://example.com/path/[foo]/bar',
- 'http://example.com/path/[foo]/bar'),
- array('http://example.com/path/foo/(bar)',
- 'http://example.com/path/foo/(bar)'),
- //Not a valid url - urls cannot contain unencoded square brackets
- array('http://example.com/path/foo/[bar]',
- 'http://example.com/path/foo/[bar]'),
- array('Hey, check out my cool site http://example.com okay?',
- 'Hey, check out my cool site http://example.com okay?'),
- array('What about parens (e.g. http://example.com/path/foo/(bar))?',
- 'What about parens (e.g. http://example.com/path/foo/(bar))?'),
- array('What about parens (e.g. http://example.com/path/foo/(bar)?',
- 'What about parens (e.g. http://example.com/path/foo/(bar)?'),
- array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
- 'What about parens (e.g. http://example.com/path/foo/(bar).)?'),
- //Not a valid url - urls cannot contain unencoded commas
- array('What about parens (e.g. http://example.com/path/(foo,bar)?',
- 'What about parens (e.g. http://example.com/path/(foo,bar)?'),
- array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
- 'Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?'),
- array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
- 'Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?'),
- array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
- 'Unbalanced too (e.g. http://example.com/path/foo/((((bar)?'),
- array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
- 'Unbalanced too (e.g. http://example.com/path/foo/(bar))))?'),
- array('file.ext',
- 'file.ext'),
- array('file.html',
- 'file.html'),
- array('file.php',
- 'file.php'),
-
- // scheme-less HTTP URLs with @ in the path: http://status.net/open-source/issues/2248
- array('http://flickr.com/photos/34807140@N05/3838905434',
- 'http://flickr.com/photos/34807140@N05/3838905434'),
- );
- }
-
- static public function linkifyProvider()
- {
- return array(
- //bare ip addresses are no longer supported
- array('127.0.0.1',
- '127.0.0.1',
- 'bare_ipv4'),
- array('127.0.0.1:99',
- '127.0.0.1:99',
- 'bare_ipv4'),
- array('127.0.0.1/Name:test.php',
- '127.0.0.1/Name:test.php',
- 'bare_ipv4'),
- array('127.0.0.1/~test',
- '127.0.0.1/~test',
- 'bare_ipv4'),
- array('127.0.0.1/+test',
- '127.0.0.1/+test',
- 'bare_ipv4'),
- array('127.0.0.1/$test',
- '127.0.0.1/$test',
- 'bare_ipv4'),
- array('127.0.0.1/\'test',
- '127.0.0.1/\'test',
- 'bare_ipv4'),
- array('127.0.0.1/"test',
- '127.0.0.1/"test',
- 'bare_ipv4'),
- array('127.0.0.1/test"test',
- '127.0.0.1/test"test',
- 'bare_ipv4'),
- array('127.0.0.1/-test',
- '127.0.0.1/-test',
- 'bare_ipv4'),
- array('127.0.0.1/_test',
- '127.0.0.1/_test',
- 'bare_ipv4'),
- array('127.0.0.1/!test',
- '127.0.0.1/!test',
- 'bare_ipv4'),
- array('127.0.0.1/*test',
- '127.0.0.1/*test',
- 'bare_ipv4'),
- array('127.0.0.1/test%20stuff',
- '127.0.0.1/test%20stuff',
- 'bare_ipv4'),
- array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
- '2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
- 'bare_ipv6'),
- array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
- '[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
- 'bare_ipv6'),
- array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
- '2001:4978:1b5:0:21d:e0ff:fe66:59ab',
- 'bare_ipv6'),
- array('example.com',
- 'example.com',
- 'bare_domains'),
- array('flickr.com/photos/34807140@N05/3838905434',
- 'flickr.com/photos/34807140@N05/3838905434',
- 'bare_domains'),
- array('What about parens (e.g. example.com/path/foo/(bar))?',
- 'What about parens (e.g. example.com/path/foo/(bar))?',
- 'bare_domains'),
- array('What about parens (e.g. example.com/path/foo/(bar)?',
- 'What about parens (e.g. example.com/path/foo/(bar)?',
- 'bare_domains'),
- array('What about parens (e.g. example.com/path/foo/(bar).)?',
- 'What about parens (e.g. example.com/path/foo/(bar).?',
- 'bare_domains'),
- array('What about parens (e.g. example.com/path/(foo,bar)?',
- 'What about parens (e.g. example.com/path/(foo,bar)?',
- 'bare_domains'),
- array('example.com',
- 'example.com',
- 'bare_domains'),
- array('example.org',
- 'example.org',
- 'bare_domains'),
- array('example.co.uk',
- 'example.co.uk',
- 'bare_domains'),
- array('www.example.co.uk',
- 'www.example.co.uk',
- 'bare_domains'),
- array('farm1.images.example.co.uk',
- 'farm1.images.example.co.uk',
- 'bare_domains'),
- array('example.museum',
- 'example.museum',
- 'bare_domains'),
- array('example.travel',
- 'example.travel',
- 'bare_domains'),
- array('example.com.',
- 'example.com.',
- 'bare_domains'),
- array('example.com?',
- 'example.com?',
- 'bare_domains'),
- array('example.com!',
- 'example.com!',
- 'bare_domains'),
- array('example.com,',
- 'example.com,',
- 'bare_domains'),
- array('example.com;',
- 'example.com;',
- 'bare_domains'),
- array('example.com:',
- 'example.com:',
- 'bare_domains'),
- array('\'example.com\'',
- '\'example.com\'',
- 'bare_domains'),
- array('"example.com"',
- '"example.com"',
- 'bare_domains'),
- array('example.com',
- 'example.com',
- 'bare_domains'),
- array('(example.com)',
- '(example.com)',
- 'bare_domains'),
- array('[example.com]',
- '[example.com]',
- 'bare_domains'),
- array('',
- '<example.com>',
- 'bare_domains'),
- array('Hey, check out my cool site example.com okay?',
- 'Hey, check out my cool site example.com okay?',
- 'bare_domains'),
- array('Hey, check out my cool site example.com.I made it.',
- 'Hey, check out my cool site example.com.I made it.',
- 'bare_domains'),
- array('Hey, check out my cool site example.com.Funny thing...',
- 'Hey, check out my cool site example.com.Funny thing...',
- 'bare_domains'),
- array('Hey, check out my cool site example.com.You will love it.',
- 'Hey, check out my cool site example.com.You will love it.',
- 'bare_domains'),
- array('example.com:8080/test.php',
- 'example.com:8080/test.php',
- 'bare_domains'),
- array('user_name+other@example.com',
- 'user_name+other@example.com',
- 'bare_domains'),
- array('user@example.com',
- 'user@example.com',
- 'bare_domains'),
- );
- }
-}
-
diff --git a/tests/UUIDTest.php b/tests/UUIDTest.php
deleted file mode 100644
index ce330d7ac6..0000000000
--- a/tests/UUIDTest.php
+++ /dev/null
@@ -1,38 +0,0 @@
-assertRegExp('/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/',
- $result);
- // Check version number
- $this->assertEquals(0x4000, hexdec(substr($result, 14, 4)) & 0xF000);
- $this->assertEquals(0x8000, hexdec(substr($result, 19, 4)) & 0xC000);
- }
-
- public function testUnique()
- {
- $reps = 100;
- $ids = array();
-
- for ($i = 0; $i < $reps; $i++) {
- $ids[] = UUID::gen();
- }
-
- $this->assertEquals(count($ids), count(array_unique($ids)), "UUIDs must be unique");
- }
-}
-