From: Diogo Cordeiro
Date: Fri, 12 Jul 2019 15:31:14 +0000 (+0100)
Subject: [CORE] Make tests great gain
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9f30c299ee93c15e4c2d24f8282201c73e4b6dbb;p=quix0rs-gnu-social.git
[CORE] Make tests great gain
---
diff --git a/composer.lock b/composer.lock
index 5d4ab05e8f..d624005f05 100644
--- a/composer.lock
+++ b/composer.lock
@@ -2125,16 +2125,16 @@
},
{
"name": "jms/serializer",
- "version": "3.0.1",
+ "version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/serializer.git",
- "reference": "bf2bae374e565f443fc01fe60695061366bd3261"
+ "reference": "7f8dc86e9168d0112b3cc38ba8cca41b17f409a0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/bf2bae374e565f443fc01fe60695061366bd3261",
- "reference": "bf2bae374e565f443fc01fe60695061366bd3261",
+ "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/7f8dc86e9168d0112b3cc38ba8cca41b17f409a0",
+ "reference": "7f8dc86e9168d0112b3cc38ba8cca41b17f409a0",
"shasum": ""
},
"require": {
@@ -2174,7 +2174,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2205,7 +2205,7 @@
"serialization",
"xml"
],
- "time": "2019-04-23T17:53:59+00:00"
+ "time": "2019-06-28T09:09:40+00:00"
},
{
"name": "justinrainbow/json-schema",
@@ -2930,16 +2930,16 @@
},
{
"name": "phpunit/php-code-coverage",
- "version": "7.0.5",
+ "version": "7.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "aed67b57d459dcab93e84a5c9703d3deb5025dff"
+ "reference": "d471d0d2b529a67c6a722dd446c4ec90881ac315"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aed67b57d459dcab93e84a5c9703d3deb5025dff",
- "reference": "aed67b57d459dcab93e84a5c9703d3deb5025dff",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d471d0d2b529a67c6a722dd446c4ec90881ac315",
+ "reference": "d471d0d2b529a67c6a722dd446c4ec90881ac315",
"shasum": ""
},
"require": {
@@ -2948,17 +2948,17 @@
"php": "^7.2",
"phpunit/php-file-iterator": "^2.0.2",
"phpunit/php-text-template": "^1.2.1",
- "phpunit/php-token-stream": "^3.0.1",
+ "phpunit/php-token-stream": "^3.0.2",
"sebastian/code-unit-reverse-lookup": "^1.0.1",
- "sebastian/environment": "^4.1",
+ "sebastian/environment": "^4.2.2",
"sebastian/version": "^2.0.1",
- "theseer/tokenizer": "^1.1"
+ "theseer/tokenizer": "^1.1.3"
},
"require-dev": {
- "phpunit/phpunit": "^8.0"
+ "phpunit/phpunit": "^8.2.2"
},
"suggest": {
- "ext-xdebug": "^2.6.1"
+ "ext-xdebug": "^2.7.2"
},
"type": "library",
"extra": {
@@ -2989,7 +2989,7 @@
"testing",
"xunit"
],
- "time": "2019-06-06T12:28:18+00:00"
+ "time": "2019-07-08T05:29:42+00:00"
},
{
"name": "phpunit/php-file-iterator",
@@ -3133,16 +3133,16 @@
},
{
"name": "phpunit/php-token-stream",
- "version": "3.0.1",
+ "version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18"
+ "reference": "c4a66b97f040e3e20b3aa2a243230a1c3a9f7c8c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18",
- "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c4a66b97f040e3e20b3aa2a243230a1c3a9f7c8c",
+ "reference": "c4a66b97f040e3e20b3aa2a243230a1c3a9f7c8c",
"shasum": ""
},
"require": {
@@ -3178,20 +3178,20 @@
"keywords": [
"tokenizer"
],
- "time": "2018-10-30T05:52:18+00:00"
+ "time": "2019-07-08T05:24:54+00:00"
},
{
"name": "phpunit/phpunit",
- "version": "8.2.3",
+ "version": "8.2.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "f67ca36860ebca7224d4573f107f79bd8ed0ba03"
+ "reference": "25fe0b5031b24722f66a75ad479a074cccc1bb37"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f67ca36860ebca7224d4573f107f79bd8ed0ba03",
- "reference": "f67ca36860ebca7224d4573f107f79bd8ed0ba03",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/25fe0b5031b24722f66a75ad479a074cccc1bb37",
+ "reference": "25fe0b5031b24722f66a75ad479a074cccc1bb37",
"shasum": ""
},
"require": {
@@ -3218,7 +3218,7 @@
"sebastian/global-state": "^3.0.0",
"sebastian/object-enumerator": "^3.0.3",
"sebastian/resource-operations": "^2.0.1",
- "sebastian/type": "^1.1.0",
+ "sebastian/type": "^1.1.3",
"sebastian/version": "^2.0.1"
},
"require-dev": {
@@ -3261,7 +3261,7 @@
"testing",
"xunit"
],
- "time": "2019-06-19T12:03:56+00:00"
+ "time": "2019-07-03T08:30:33+00:00"
},
{
"name": "pimple/pimple",
@@ -4101,16 +4101,16 @@
},
{
"name": "sebastian/type",
- "version": "1.1.2",
+ "version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
- "reference": "251ca774d58181fe1d3eda68843264eaae7e07ef"
+ "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/251ca774d58181fe1d3eda68843264eaae7e07ef",
- "reference": "251ca774d58181fe1d3eda68843264eaae7e07ef",
+ "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3",
+ "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3",
"shasum": ""
},
"require": {
@@ -4143,7 +4143,7 @@
],
"description": "Collection of value objects that represent the types of the PHP type system",
"homepage": "https://github.com/sebastianbergmann/type",
- "time": "2019-06-19T06:39:12+00:00"
+ "time": "2019-07-02T08:10:15+00:00"
},
{
"name": "sebastian/version",
diff --git a/lib/callable_left_curry.php b/lib/callable_left_curry.php
deleted file mode 100644
index 37c9c1c18e..0000000000
--- a/lib/callable_left_curry.php
+++ /dev/null
@@ -1,36 +0,0 @@
-.
- */
-
-/**
- * PHP 5.3 implementation of function currying, using native closures.
- * On 5.2 and lower we use the fallback implementation in util.php
- *
- * @param callback $fn
- * @param ... any remaining arguments will be appended to call-time params
- * @return callback
- */
-function callable_left_curry($fn) {
- $extra_args = func_get_args();
- array_shift($extra_args);
- return function() use ($fn, $extra_args) {
- $args = func_get_args();
- return call_user_func_array($fn,
- array_merge($args, $extra_args));
- };
-}
diff --git a/lib/callableleftcurry.php b/lib/callableleftcurry.php
new file mode 100644
index 0000000000..8ad2e61c27
--- /dev/null
+++ b/lib/callableleftcurry.php
@@ -0,0 +1,36 @@
+.
+ */
+
+/**
+ * PHP 5.3 implementation of function currying, using native closures.
+ * On 5.2 and lower we use the fallback implementation in util.php
+ *
+ * @param callback $fn
+ * @param ... any remaining arguments will be appended to call-time params
+ * @return callback
+ */
+function callableLeftCurry($fn) {
+ $extra_args = func_get_args();
+ array_shift($extra_args);
+ return function() use ($fn, $extra_args) {
+ $args = func_get_args();
+ return call_user_func_array($fn,
+ array_merge($args, $extra_args));
+ };
+}
diff --git a/lib/common.php b/lib/common.php
index c31c45f626..4a74fb5e7f 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -1,25 +1,28 @@
.
- */
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// GNU social is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with GNU social. If not, see .
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+defined('GNUSOCIAL') || die();
-// All the fun stuff to actually initialize StatusNet's framework code,
+/* Work internally in UTC */
+date_default_timezone_set('UTC');
+
+/* Work internally with UTF-8 */
+mb_internal_encoding('UTF-8');
+
+// All the fun stuff to actually initialize GNU social's framework code,
// without loading up a site configuration.
require_once INSTALLDIR . '/lib/framework.php';
diff --git a/lib/event.php b/lib/event.php
index e6bb41091e..5ece77edf3 100644
--- a/lib/event.php
+++ b/lib/event.php
@@ -1,35 +1,20 @@
.
- *
- * @category Event
- * @package StatusNet
- * @author Evan Prodromou
- * @copyright 2008 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- */
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// GNU social is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with GNU social. If not, see .
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Class for events
@@ -37,14 +22,13 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* This "class" two static functions for managing events in the StatusNet code.
*
* @category Event
- * @package StatusNet
+ * @package GNU social
* @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2010-2019 Free Software Foundation, Inc http://www.fsf.org
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
* @todo Define a system for using Event instances
*/
-
class Event {
/* Global array of hooks, mapping eventname => array of callables */
diff --git a/lib/gnusocial.php b/lib/gnusocial.php
index 789cece2be..43c7c60ad2 100644
--- a/lib/gnusocial.php
+++ b/lib/gnusocial.php
@@ -1,24 +1,20 @@
.
- *
- */
-
-if (!defined('GNUSOCIAL')) { exit(1); }
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// GNU social is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with GNU social. If not, see .
+
+defined('GNUSOCIAL') || die();
global $config, $_server, $_path;
@@ -343,11 +339,6 @@ class GNUsocial
$config['db'] = &$_PEAR->getStaticProperty('DB_DataObject','options');
$config['db'] = $default['db'];
-
- if (function_exists('date_default_timezone_set')) {
- /* Work internally in UTC */
- date_default_timezone_set('UTC');
- }
}
public static function loadSiteProfile($name)
diff --git a/lib/language.php b/lib/language.php
index f0144b4106..c70adb8ea5 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -1,34 +1,33 @@
.
+
/**
- * GNU social - a federating social network
- *
- * utility functions for i18n
- *
- * LICENCE: This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Utility functions for i18n
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- * @category I18n
- * @package GNU social
- * @author Matthew Gregg
- * @author Ciaran Gultnieks
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @category I18n
+ * @package GNU social
+ * @author Matthew Gregg
+ * @author Ciaran Gultnieks
+ * @author Evan Prodromou
+ * @author Diogo Cordeiro
+ * @copyright 2010-2019 Free Software Foundation, Inc http://www.fsf.org
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
// Locale category constants are usually predefined, but may not be
// on some systems such as Win32.
diff --git a/lib/plugin.php b/lib/plugin.php
index 2625bf3520..cd0c9c6bad 100644
--- a/lib/plugin.php
+++ b/lib/plugin.php
@@ -1,35 +1,20 @@
.
- *
- * @category Plugin
- * @package StatusNet
- * @author Evan Prodromou
- * @copyright 2008 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- */
-
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// GNU social is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with GNU social. If not, see .
+
+defined('GNUSOCIAL') || die();
/**
* Base class for plugins
@@ -45,14 +30,13 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* initialize() and cleanup() methods, respectively.
*
* @category Plugin
- * @package StatusNet
+ * @package GNU social
* @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2010-2019 Free Software Foundation, Inc http://www.fsf.org
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
* @see Event
*/
-
class Plugin
{
function __construct()
diff --git a/lib/util.php b/lib/util.php
index 0866b32d55..966c415024 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1040,7 +1040,7 @@ function common_replace_urls_callback($text, $callback, $arg = null)
'#ixu';
//preg_match_all($regex,$text,$matches);
//print_r($matches);
- return preg_replace_callback($regex, callable_left_curry('callback_helper', $callback, $arg), $text);
+ return preg_replace_callback($regex, callableLeftCurry('callback_helper', $callback, $arg), $text);
}
/**
@@ -1102,7 +1102,7 @@ function callback_helper($matches, $callback, $arg = null)
return substr($matches[0], 0, $left) . $result . substr($matches[0], $right);
}
-require_once INSTALLDIR . "/lib/callable_left_curry.php";
+require_once INSTALLDIR . "/lib/callableleftcurry.php";
function common_linkify($url)
{
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 0000000000..b57ab9c7db
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,26 @@
+
+
+
+
+ ./tests/Core
+
+
+ ./tests/Media
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/ActivityGenerationTests.php b/tests/ActivityGenerationTests.php
deleted file mode 100644
index 21fe32a58b..0000000000
--- a/tests/ActivityGenerationTests.php
+++ /dev/null
@@ -1,567 +0,0 @@
- $authorNick1,
- 'email' => $authorNick1 . '@example.net',
- 'email_confirmed' => true));
-
- self::$author2 = User::register(array('nickname' => $authorNick2,
- 'email' => $authorNick2 . '@example.net',
- 'email_confirmed' => true));
-
- self::$targetUser1 = User::register(array('nickname' => $targetNick1,
- 'email' => $targetNick1 . '@example.net',
- 'email_confirmed' => true));
-
- self::$targetUser2 = User::register(array('nickname' => $targetNick2,
- 'email' => $targetNick2 . '@example.net',
- 'email_confirmed' => true));
-
- self::$targetGroup1 = User_group::register(array('nickname' => $groupNick1,
- 'userid' => self::$author1->id,
- 'aliases' => array(),
- 'local' => true,
- 'location' => null,
- 'description' => null,
- 'fullname' => null,
- 'homepage' => null,
- 'mainpage' => null));
- self::$targetGroup2 = User_group::register(array('nickname' => $groupNick2,
- 'userid' => self::$author1->id,
- 'aliases' => array(),
- 'local' => true,
- 'location' => null,
- 'description' => null,
- 'fullname' => null,
- 'homepage' => null,
- 'mainpage' => null));
- } catch (Exception $e) {
- self::tearDownAfterClass();
- throw $e;
- }
- }
-
- public function testBasicNoticeActivity()
- {
- $notice = $this->_fakeNotice();
-
- $entry = $notice->asAtomEntry(true);
-
- $element = $this->_entryToElement($entry, false);
-
- $this->assertEquals($notice->getUri(), ActivityUtils::childContent($element, 'id'));
- $this->assertEquals('New note by '. self::$author1->nickname, ActivityUtils::childContent($element, 'title'));
- $this->assertEquals($notice->rendered, ActivityUtils::childContent($element, 'content'));
- $this->assertEquals(strtotime($notice->created), strtotime(ActivityUtils::childContent($element, 'published')));
- $this->assertEquals(strtotime($notice->created), strtotime(ActivityUtils::childContent($element, 'updated')));
- $this->assertEquals(ActivityVerb::POST, ActivityUtils::childContent($element, 'verb', Activity::SPEC));
- $this->assertEquals(ActivityObject::NOTE, ActivityUtils::childContent($element, 'object-type', Activity::SPEC));
- }
-
- public function testNamespaceFlag()
- {
- $notice = $this->_fakeNotice();
-
- $entry = $notice->asAtomEntry(true);
-
- $element = $this->_entryToElement($entry, false);
-
- $this->assertTrue($element->hasAttribute('xmlns'));
- $this->assertTrue($element->hasAttribute('xmlns:thr'));
- $this->assertTrue($element->hasAttribute('xmlns:georss'));
- $this->assertTrue($element->hasAttribute('xmlns:activity'));
- $this->assertTrue($element->hasAttribute('xmlns:media'));
- $this->assertTrue($element->hasAttribute('xmlns:poco'));
- $this->assertTrue($element->hasAttribute('xmlns:ostatus'));
- $this->assertTrue($element->hasAttribute('xmlns:statusnet'));
-
- $entry = $notice->asAtomEntry(false);
-
- $element = $this->_entryToElement($entry, true);
-
- $this->assertFalse($element->hasAttribute('xmlns'));
- $this->assertFalse($element->hasAttribute('xmlns:thr'));
- $this->assertFalse($element->hasAttribute('xmlns:georss'));
- $this->assertFalse($element->hasAttribute('xmlns:activity'));
- $this->assertFalse($element->hasAttribute('xmlns:media'));
- $this->assertFalse($element->hasAttribute('xmlns:poco'));
- $this->assertFalse($element->hasAttribute('xmlns:ostatus'));
- $this->assertFalse($element->hasAttribute('xmlns:statusnet'));
- }
-
- public function testSourceFlag()
- {
- $notice = $this->_fakeNotice();
-
- // Test with no source
-
- $entry = $notice->asAtomEntry(false, false);
-
- $element = $this->_entryToElement($entry, true);
-
- $source = ActivityUtils::child($element, 'source');
-
- $this->assertNull($source);
-
- // Test with source
-
- $entry = $notice->asAtomEntry(false, true);
-
- $element = $this->_entryToElement($entry, true);
-
- $source = ActivityUtils::child($element, 'source');
-
- $this->assertNotNull($source);
- }
-
- public function testSourceContent()
- {
- $notice = $this->_fakeNotice();
- // make a time difference!
- sleep(2);
- $notice2 = $this->_fakeNotice();
-
- $entry = $notice->asAtomEntry(false, true);
-
- $element = $this->_entryToElement($entry, true);
-
- $source = ActivityUtils::child($element, 'source');
-
- $atomUrl = common_local_url('ApiTimelineUser', array('id' => self::$author1->id, 'format' => 'atom'));
-
- $profile = self::$author1->getProfile();
-
- $this->assertEquals($atomUrl, ActivityUtils::childContent($source, 'id'));
- $this->assertEquals($atomUrl, ActivityUtils::getLink($source, 'self', 'application/atom+xml'));
- $this->assertEquals($profile->profileurl, ActivityUtils::getPermalink($source));
- $this->assertEquals(strtotime($notice2->created), strtotime(ActivityUtils::childContent($source, 'updated')));
- // XXX: do we care here?
- $this->assertFalse(is_null(ActivityUtils::childContent($source, 'title')));
- $this->assertEquals(common_config('license', 'url'), ActivityUtils::getLink($source, 'license'));
- }
-
- public function testAuthorFlag()
- {
- $notice = $this->_fakeNotice();
-
- // Test with no author
-
- $entry = $notice->asAtomEntry(false, false, false);
-
- $element = $this->_entryToElement($entry, true);
-
- $this->assertNull(ActivityUtils::child($element, 'author'));
- $this->assertNull(ActivityUtils::child($element, 'actor', Activity::SPEC));
-
- // Test with source
-
- $entry = $notice->asAtomEntry(false, false, true);
-
- $element = $this->_entryToElement($entry, true);
-
- $author = ActivityUtils::child($element, 'author');
- $actor = ActivityUtils::child($element, 'actor', Activity::SPEC);
-
- $this->assertFalse(is_null($author));
- $this->assertTrue(is_null($actor)); // is obsolete, no longer added
- }
-
- public function testAuthorContent()
- {
- $notice = $this->_fakeNotice();
-
- // Test with author
-
- $entry = $notice->asAtomEntry(false, false, true);
-
- $element = $this->_entryToElement($entry, true);
-
- $author = ActivityUtils::child($element, 'author');
-
- $this->assertEquals(self::$author1->getNickname(), ActivityUtils::childContent($author, 'name'));
- $this->assertEquals(self::$author1->getUri(), ActivityUtils::childContent($author, 'uri'));
- }
-
- /**
- * We no longer create entries, they have merged to
- */
- public function testActorContent()
- {
- $notice = $this->_fakeNotice();
-
- // Test with author
-
- $entry = $notice->asAtomEntry(false, false, true);
-
- $element = $this->_entryToElement($entry, true);
-
- $actor = ActivityUtils::child($element, 'actor', Activity::SPEC);
-
- $this->assertEquals($actor, null);
- }
-
- public function testReplyLink()
- {
- $orig = $this->_fakeNotice(self::$targetUser1);
-
- $text = "@" . self::$targetUser1->nickname . " reply text " . common_random_hexstr(4);
-
- $reply = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
-
- $entry = $reply->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $irt = ActivityUtils::child($element, 'in-reply-to', 'http://purl.org/syndication/thread/1.0');
-
- $this->assertNotNull($irt);
- $this->assertEquals($orig->getUri(), $irt->getAttribute('ref'));
- $this->assertEquals($orig->getUrl(), $irt->getAttribute('href'));
- }
-
- public function testReplyAttention()
- {
- $orig = $this->_fakeNotice(self::$targetUser1);
-
- $text = "@" . self::$targetUser1->nickname . " reply text " . common_random_hexstr(4);
-
- $reply = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
-
- $entry = $reply->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $this->assertEquals(self::$targetUser1->getUri(), ActivityUtils::getLink($element, 'mentioned'));
- }
-
- public function testMultipleReplyAttention()
- {
- $orig = $this->_fakeNotice(self::$targetUser1);
-
- $text = "@" . self::$targetUser1->nickname . " reply text " . common_random_hexstr(4);
-
- $reply = Notice::saveNew(self::$targetUser2->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
-
- $text = "@" . self::$targetUser1->nickname . " @" . self::$targetUser2->nickname . " reply text " . common_random_hexstr(4);
-
- $reply2 = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null, 'reply_to' => $reply->id));
-
- $entry = $reply2->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $links = ActivityUtils::getLinks($element, 'mentioned');
-
- $hrefs = array();
-
- foreach ($links as $link) {
- $hrefs[] = $link->getAttribute('href');
- }
-
- $this->assertTrue(in_array(self::$targetUser1->getUri(), $hrefs));
- $this->assertTrue(in_array(self::$targetUser2->getUri(), $hrefs));
- }
-
- public function testGroupPostAttention()
- {
- $text = "!" . self::$targetGroup1->nickname . " reply text " . common_random_hexstr(4);
-
- $notice = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null));
-
- $entry = $notice->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $this->assertEquals(self::$targetGroup1->getUri(), ActivityUtils::getLink($element, 'mentioned'));
- }
-
- public function testMultipleGroupPostAttention()
- {
- $text = "!" . self::$targetGroup1->nickname . " !" . self::$targetGroup2->nickname . " reply text " . common_random_hexstr(4);
-
- $notice = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null));
-
- $entry = $notice->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $links = ActivityUtils::getLinks($element, 'mentioned');
-
- $hrefs = array();
-
- foreach ($links as $link) {
- $hrefs[] = $link->getAttribute('href');
- }
-
- $this->assertTrue(in_array(self::$targetGroup1->getUri(), $hrefs));
- $this->assertTrue(in_array(self::$targetGroup2->getUri(), $hrefs));
-
- }
-
- public function testRepeatLink()
- {
- $notice = $this->_fakeNotice(self::$author1);
- $repeat = $notice->repeat(self::$author2->getProfile(), 'test');
-
- $entry = $repeat->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $noticeInfo = ActivityUtils::child($element, 'notice_info', 'http://status.net/schema/api/1/');
-
- $this->assertNotNull($noticeInfo);
- $this->assertEquals($notice->id, $noticeInfo->getAttribute('repeat_of'));
- $this->assertEquals($repeat->id, $noticeInfo->getAttribute('local_id'));
- }
-
- public function testTag()
- {
- $tag1 = common_random_hexstr(4);
-
- $notice = $this->_fakeNotice(self::$author1, '#' . $tag1);
-
- $entry = $notice->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $category = ActivityUtils::child($element, 'category');
-
- $this->assertNotNull($category);
- $this->assertEquals($tag1, $category->getAttribute('term'));
- }
-
- public function testMultiTag()
- {
- $tag1 = common_random_hexstr(4);
- $tag2 = common_random_hexstr(4);
-
- $notice = $this->_fakeNotice(self::$author1, '#' . $tag1 . ' #' . $tag2);
-
- $entry = $notice->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $categories = $element->getElementsByTagName('category');
-
- $this->assertNotNull($categories);
- $this->assertEquals(2, $categories->length);
-
- $terms = array();
-
- for ($i = 0; $i < $categories->length; $i++) {
- $cat = $categories->item($i);
- $terms[] = $cat->getAttribute('term');
- }
-
- $this->assertTrue(in_array($tag1, $terms));
- $this->assertTrue(in_array($tag2, $terms));
- }
-
- public function testGeotaggedActivity()
- {
- $notice = Notice::saveNew(self::$author1->id, common_random_hexstr(4), 'test', array('uri' => null, 'lat' => 45.5, 'lon' => -73.6));
-
- $entry = $notice->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $this->assertEquals('45.5000000 -73.6000000', ActivityUtils::childContent($element, 'point', "http://www.georss.org/georss"));
- }
-
- public function testNoticeInfo()
- {
- $notice = $this->_fakeNotice();
-
- $entry = $notice->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
-
- $this->assertEquals($notice->id, $noticeInfo->getAttribute('local_id'));
- $this->assertEquals($notice->source, $noticeInfo->getAttribute('source'));
- $this->assertEquals('', $noticeInfo->getAttribute('repeat_of'));
- $this->assertEquals('', $noticeInfo->getAttribute('repeated'));
-// $this->assertEquals('', $noticeInfo->getAttribute('favorite'));
- $this->assertEquals('', $noticeInfo->getAttribute('source_link'));
- }
-
- public function testNoticeInfoRepeatOf()
- {
- $notice = $this->_fakeNotice();
-
- $repeat = $notice->repeat(self::$author2->getProfile(), 'test');
-
- $entry = $repeat->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
-
- $this->assertEquals($notice->id, $noticeInfo->getAttribute('repeat_of'));
- }
-
- public function testNoticeInfoRepeated()
- {
- $notice = $this->_fakeNotice();
-
- $repeat = $notice->repeat(self::$author2->getProfile(), 'test');
-
- $entry = $notice->asAtomEntry(false, false, false, self::$author2->getProfile());
-
- $element = $this->_entryToElement($entry, true);
-
- $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
-
- $this->assertEquals('true', $noticeInfo->getAttribute('repeated'));
-
- $entry = $notice->asAtomEntry(false, false, false, self::$targetUser1->getProfile());
-
- $element = $this->_entryToElement($entry, true);
-
- $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
-
- $this->assertEquals('false', $noticeInfo->getAttribute('repeated'));
- }
-
-/* public function testNoticeInfoFave()
- {
- $notice = $this->_fakeNotice();
-
- $fave = Fave::addNew(self::$author2->getProfile(), $notice);
-
- // Should be set if user has faved
-
- $entry = $notice->asAtomEntry(false, false, false, self::$author2);
-
- $element = $this->_entryToElement($entry, true);
-
- $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
-
- $this->assertEquals('true', $noticeInfo->getAttribute('favorite'));
-
- // Shouldn't be set if user has not faved
-
- $entry = $notice->asAtomEntry(false, false, false, self::$targetUser1);
-
- $element = $this->_entryToElement($entry, true);
-
- $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
-
- $this->assertEquals('false', $noticeInfo->getAttribute('favorite'));
- }*/
-
- public function testConversationLink()
- {
- $orig = $this->_fakeNotice(self::$targetUser1);
-
- $text = "@" . self::$targetUser1->nickname . " reply text " . common_random_hexstr(4);
-
- $reply = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
-
- $conv = Conversation::getKV('id', $reply->conversation);
-
- $entry = $reply->asAtomEntry();
-
- $element = $this->_entryToElement($entry, true);
-
- $this->assertEquals($conv->getUrl(), ActivityUtils::getLink($element, 'ostatus:conversation'));
- }
-
- public static function tearDownAfterClass()
- {
- if (!is_null(self::$author1)) {
- self::$author1->getProfile()->delete();
- }
-
- if (!is_null(self::$author2)) {
- self::$author2->getProfile()->delete();
- }
-
- if (!is_null(self::$targetUser1)) {
- self::$targetUser1->getProfile()->delete();
- }
-
- if (!is_null(self::$targetUser2)) {
- self::$targetUser2->getProfile()->delete();
- }
-
- if (!is_null(self::$targetGroup1)) {
- self::$targetGroup1->delete();
- }
-
- if (!is_null(self::$targetGroup2)) {
- self::$targetGroup2->delete();
- }
- }
-
- private function _fakeNotice($user = null, $text = null)
- {
- if (empty($user)) {
- $user = self::$author1;
- }
-
- if (empty($text)) {
- $text = "fake-o text-o " . common_random_hexstr(32);
- }
-
- return Notice::saveNew($user->id, $text, 'test', array('uri' => null));
- }
-
- private function _entryToElement($entry, $namespace = false)
- {
- $xml = ''."\n\n";
- $xml .= '' . "\n";
- $doc = DOMDocument::loadXML($xml);
- $feed = $doc->documentElement;
- $entries = $feed->getElementsByTagName('entry');
-
- return $entries->item(0);
- }
-}
diff --git a/tests/ActivityParseTests.php b/tests/ActivityParseTests.php
deleted file mode 100644
index 566318e9ea..0000000000
--- a/tests/ActivityParseTests.php
+++ /dev/null
@@ -1,1044 +0,0 @@
-documentElement;
- $entries = $feed->getElementsByTagName('entry');
- $entry = $entries->item(0);
- $act = new Activity($entry, $feed);
- $this->assertFalse(empty($act));
- $this->assertFalse(empty($act->objects[0]));
-
- $object = $act->objects[0];
- $this->assertEquals($object->verb, ActivityVerb::POST);
- }
-
- public function testGSReweet() {
- global $_gs_retweet;
- $dom = DOMDocument::loadXML($_gs_retweet);
- $feed = $dom->documentElement;
- $entries = $feed->getElementsByTagName('entry');
- $entry = $entries->item(0);
- $act = new Activity($entry, $feed);
- $this->assertFalse(empty($act));
- $this->assertFalse(empty($act->objects[0]));
-
- $object = $act->objects[0];
- $this->assertEquals($object->verb, ActivityVerb::POST);
- }
-
- public function testExample1()
- {
- global $_example1;
- $dom = DOMDocument::loadXML($_example1);
- $act = new Activity($dom->documentElement);
-
- $this->assertFalse(empty($act));
-
- $this->assertEquals(1243860840, $act->time);
- $this->assertEquals(ActivityVerb::POST, $act->verb);
-
- $this->assertFalse(empty($act->objects[0]));
- $this->assertEquals('Punctuation Changeset', $act->objects[0]->title);
- $this->assertEquals('http://versioncentral.example.org/activity/changeset', $act->objects[0]->type);
- $this->assertEquals('Fixing punctuation because it makes it more readable.', $act->objects[0]->summary);
- $this->assertEquals('tag:versioncentral.example.org,2009:/change/1643245', $act->objects[0]->id);
- }
-
- public function testExample2()
- {
- global $_example2;
- $dom = DOMDocument::loadXML($_example2);
- $act = new Activity($dom->documentElement);
-
- $this->assertFalse(empty($act));
- // Did we handle correctly with a typical payload?
- $this->assertEquals("Geraldine posted a Photo on PhotoPanic
\n " .
- " ", trim($act->content));
- }
-
- public function testExample3()
- {
- global $_example3;
- $dom = DOMDocument::loadXML($_example3);
-
- $feed = $dom->documentElement;
-
- $entries = $feed->getElementsByTagName('entry');
-
- $entry = $entries->item(0);
-
- $act = new Activity($entry, $feed);
-
- $this->assertFalse(empty($act));
- $this->assertEquals(1071340202, $act->time);
- $this->assertEquals('http://example.org/2003/12/13/atom03.html', $act->link);
-
- $this->assertEquals($act->verb, ActivityVerb::POST);
-
- $this->assertFalse(empty($act->actor));
- $this->assertEquals(ActivityObject::PERSON, $act->actor->type);
- $this->assertEquals('John Doe', $act->actor->title);
- $this->assertEquals('mailto:johndoe@example.com', $act->actor->id);
-
- $this->assertFalse(empty($act->objects[0]));
- $this->assertEquals(ActivityObject::NOTE, $act->objects[0]->type);
- $this->assertEquals('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', $act->objects[0]->id);
- $this->assertEquals('Atom-Powered Robots Run Amok', $act->objects[0]->title);
- $this->assertEquals('Some text.', $act->objects[0]->summary);
- $this->assertEquals('http://example.org/2003/12/13/atom03.html', $act->objects[0]->link);
-
- $this->assertFalse(empty($act->context));
-
- $this->assertTrue(empty($act->target));
-
- $this->assertEquals($act->entry, $entry);
- $this->assertEquals($act->feed, $feed);
- }
-
- public function testExample4()
- {
- global $_example4;
- $dom = DOMDocument::loadXML($_example4);
-
- $entry = $dom->documentElement;
-
- $act = new Activity($entry);
-
- $this->assertFalse(empty($act));
- $this->assertEquals(1266547958, $act->time);
- $this->assertEquals('http://example.net/notice/14', $act->link);
-
- $this->assertFalse(empty($act->context));
- $this->assertEquals('http://example.net/notice/12', $act->context->replyToID);
- $this->assertEquals('http://example.net/notice/12', $act->context->replyToUrl);
- $this->assertEquals('http://example.net/conversation/11', $act->context->conversation);
- $this->assertEquals(array('http://example.net/user/1'), array_keys($act->context->attention));
-
- $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 ');
-
- $this->assertFalse(empty($act->actor));
- }
-
- public function testExample5()
- {
- global $_example5;
- $dom = DOMDocument::loadXML($_example5);
-
- $feed = $dom->documentElement;
-
- // @todo Test feed elements
-
- $entries = $feed->getElementsByTagName('entry');
- $entry = $entries->item(0);
-
- $act = new Activity($entry, $feed);
-
- // Post
- $this->assertEquals($act->verb, ActivityVerb::POST);
- $this->assertFalse(empty($act->context));
-
- // Actor w/Portable Contacts stuff
- $this->assertFalse(empty($act->actor));
- $this->assertEquals($act->actor->type, ActivityObject::PERSON);
- $this->assertEquals($act->actor->title, 'Test User');
- $this->assertEquals($act->actor->id, 'http://example.net/mysite/user/3');
- $this->assertEquals($act->actor->link, 'http://example.net/mysite/testuser');
-
- $avatars = $act->actor->avatarLinks;
-
- $this->assertEquals(
- $avatars[0]->url,
- 'http://example.net/mysite/avatar/3-96-20100224004207.jpeg'
- );
-
- $this->assertEquals($act->actor->displayName, 'Test User');
-
- $poco = $act->actor->poco;
- $this->assertEquals($poco->preferredUsername, 'testuser');
- $this->assertEquals($poco->address->formatted, 'San Francisco, CA');
- $this->assertEquals($poco->urls[0]->type, 'homepage');
- $this->assertEquals($poco->urls[0]->value, 'http://example.com/blog.html');
- $this->assertEquals($poco->urls[0]->primary, 'true');
- $this->assertEquals($act->actor->geopoint, '37.7749295 -122.4194155');
- }
-
- public function testExample6()
- {
- global $_example6;
-
- $dom = DOMDocument::loadXML($_example6);
-
- $rss = $dom->documentElement;
-
- $channels = $dom->getElementsByTagName('channel');
-
- $channel = $channels->item(0);
-
- $items = $channel->getElementsByTagName('item');
-
- $item = $items->item(0);
-
- $act = new Activity($item, $channel);
-
- $this->assertEquals($act->verb, ActivityVerb::POST);
-
- $this->assertEquals($act->id, 'http://en.blog.wordpress.com/?p=3857');
- $this->assertEquals($act->link, 'http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/');
- $this->assertEquals($act->title, 'Rub-a-Dub-Dub in the PubSubHubbub');
- $this->assertEquals($act->time, 1267634892);
-
- $actor = $act->actor;
-
- $this->assertFalse(empty($actor));
- $this->assertEquals($actor->title, "Joseph Scott");
- }
-
- public function testExample7()
- {
- global $_example7;
-
- $dom = DOMDocument::loadXML($_example7);
-
- $rss = $dom->documentElement;
-
- $channels = $dom->getElementsByTagName('channel');
-
- $channel = $channels->item(0);
-
- $items = $channel->getElementsByTagName('item');
-
- $item = $items->item(0);
-
- $act = new Activity($item, $channel);
-
- $this->assertEquals(ActivityVerb::POST, $act->verb);
- $this->assertEquals('http://evanpro.posterous.com/checking-out-captain-bones', $act->link);
- $this->assertEquals('http://evanpro.posterous.com/checking-out-captain-bones', $act->id);
- $this->assertEquals('Checking out captain bones', $act->title);
- $this->assertEquals(1269095551, $act->time);
-
- $actor = $act->actor;
-
- $this->assertEquals(ActivityObject::PERSON, $actor->type);
- $this->assertEquals('http://posterous.com/people/3sDslhaepotz', $actor->id);
- $this->assertEquals('Evan Prodromou', $actor->title);
- $this->assertNull($actor->summary);
- $this->assertNull($actor->content);
- $this->assertEquals('http://posterous.com/people/3sDslhaepotz', $actor->link);
- $this->assertNull($actor->source);
- $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);
- $this->assertNotNull($actor->poco);
- $this->assertEquals('evanpro', $actor->poco->preferredUsername);
- $this->assertEquals('Evan Prodromou', $actor->poco->displayName);
- $this->assertNull($actor->poco->note);
- $this->assertNull($actor->poco->address);
- $this->assertEquals(0, count($actor->poco->urls));
- }
-
- // Media test - cliqset
- public function testExample8()
- {
- global $_example8;
- $dom = DOMDocument::loadXML($_example8);
-
- $feed = $dom->documentElement;
-
- $entries = $feed->getElementsByTagName('entry');
-
- $entry = $entries->item(0);
-
- $act = new Activity($entry, $feed);
-
- $this->assertFalse(empty($act));
- $this->assertEquals($act->time, 1269221753);
- $this->assertEquals($act->verb, ActivityVerb::POST);
- $this->assertEquals($act->summary, 'zcopley posted 5 photos on Flickr');
-
- $this->assertFalse(empty($act->objects));
- $this->assertEquals(sizeof($act->objects), 5);
-
- $this->assertEquals($act->objects[0]->type, ActivityObject::PHOTO);
- $this->assertEquals($act->objects[0]->title, 'IMG_1368');
- $this->assertNull($act->objects[0]->description);
- $this->assertEquals(
- $act->objects[0]->thumbnail,
- 'http://media.cliqset.com/6f6fbee9d7dfbffc73b6ef626275eb5f_thumb.jpg'
- );
- $this->assertEquals(
- $act->objects[0]->link,
- 'http://www.flickr.com/photos/zcopley/4452933806/'
- );
-
- $this->assertEquals($act->objects[1]->type, ActivityObject::PHOTO);
- $this->assertEquals($act->objects[1]->title, 'IMG_1365');
- $this->assertNull($act->objects[1]->description);
- $this->assertEquals(
- $act->objects[1]->thumbnail,
- 'http://media.cliqset.com/b8f3932cd0bba1b27f7c8b3ef986915e_thumb.jpg'
- );
- $this->assertEquals(
- $act->objects[1]->link,
- 'http://www.flickr.com/photos/zcopley/4442630390/'
- );
-
- $this->assertEquals($act->objects[2]->type, ActivityObject::PHOTO);
- $this->assertEquals($act->objects[2]->title, 'Classic');
- $this->assertEquals(
- $act->objects[2]->description,
- '-Powered by pikchur.com/n0u'
- );
- $this->assertEquals(
- $act->objects[2]->thumbnail,
- 'http://media.cliqset.com/fc54c15f850b7a9a8efa644087a48c91_thumb.jpg'
- );
- $this->assertEquals(
- $act->objects[2]->link,
- 'http://www.flickr.com/photos/zcopley/4430754103/'
- );
-
- $this->assertEquals($act->objects[3]->type, ActivityObject::PHOTO);
- $this->assertEquals($act->objects[3]->title, 'IMG_1363');
- $this->assertNull($act->objects[3]->description);
-
- $this->assertEquals(
- $act->objects[3]->thumbnail,
- 'http://media.cliqset.com/4b1d307c9217e2114391a8b229d612cb_thumb.jpg'
- );
- $this->assertEquals(
- $act->objects[3]->link,
- 'http://www.flickr.com/photos/zcopley/4416969717/'
- );
-
- $this->assertEquals($act->objects[4]->type, ActivityObject::PHOTO);
- $this->assertEquals($act->objects[4]->title, 'IMG_1361');
- $this->assertNull($act->objects[4]->description);
-
- $this->assertEquals(
- $act->objects[4]->thumbnail,
- 'http://media.cliqset.com/23d9b4b96b286e0347d36052f22f6e60_thumb.jpg'
- );
- $this->assertEquals(
- $act->objects[4]->link,
- 'http://www.flickr.com/photos/zcopley/4417734232/'
- );
-
- }
-
- 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>"));
- foreach ($tests as $data) {
- list($source, $output) = $data;
- $xml = "" .
- "http://example.com/fakeid " .
- "Test " .
- "Atom content tests " .
- $source .
- " ";
- $dom = DOMDocument::loadXML($xml);
- $act = new Activity($dom->documentElement);
-
- $this->assertFalse(empty($act));
- $this->assertEquals($output, trim($act->content));
- }
- }
-
- 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>"));
- foreach ($tests as $data) {
- list($source, $output) = $data;
- $xml = "- " .
- "
http://example.com/fakeid " .
- "RSS content tests " .
- $source .
- " ";
- $dom = DOMDocument::loadXML($xml);
- $act = new Activity($dom->documentElement);
-
- $this->assertFalse(empty($act));
- $this->assertEquals($output, trim($act->content));
- }
- }
-
- public function testExample10()
- {
- global $_example10;
- $dom = new DOMDocument();
- $dom->loadXML($_example10);
-
- // example 10 is a PuSH item of a post on a group feed, as generated
- // by 0.9.7 code after migration away from to
- $feed = $dom->documentElement;
- $entry = $dom->getElementsByTagName('entry')->item(0);
- $expected = 'http://lazarus.local/mublog/user/557';
-
- // Reading just the entry alone should pick up its own
- // as the actor.
- $act = new Activity($entry);
- $this->assertEquals($act->actor->id, $expected);
-
- // Reading the entry in feed context used to be buggy, picking up
- // the feed's which referred to the group.
- // It should now be returning the expected author entry...
- $act = new Activity($entry, $feed);
- $this->assertEquals($act->actor->id, $expected);
- }
-
- public function testBookmarkRelated()
- {
- global $_example11;
- $dom = new DOMDocument();
- $dom->loadXML($_example11);
-
- $feed = $dom->documentElement;
- $entry = $dom->getElementsByTagName('entry')->item(0);
-
- $expected = 'http://blog.teambox.com/open-source-companies';
-
- $links = ActivityUtils::getLinks($entry, 'related');
-
- $this->assertFalse(empty($links));
- $this->assertTrue(is_array($links));
- $this->assertEquals(count($links), 1);
-
- $url = $links[0]->getAttribute('href');
-
- $this->assertEquals($url, $expected);
- }
-}
-
-$_example1 = <<
-
- tag:versioncentral.example.org,2009:/commit/1643245
- 2009-06-01T12:54:00Z
- Geraldine committed a change to yate
- Geraldine just committed a change to yate on VersionCentral
-
- http://activitystrea.ms/schema/1.0/post
- http://versioncentral.example.org/activity/commit
-
- http://versioncentral.example.org/activity/changeset
- tag:versioncentral.example.org,2009:/change/1643245
- Punctuation Changeset
- Fixing punctuation because it makes it more readable.
-
-
-
-EXAMPLE1;
-
-$_example2 = <<
-
- tag:photopanic.example.com,2008:activity01
- Geraldine posted a Photo on PhotoPanic
- 2008-11-02T15:29:00Z
-
-
- http://activitystrea.ms/schema/1.0/post
-
-
- tag:photopanic.example.com,2008:photo01
- My Cat
- 2008-11-02T15:29:00Z
-
-
- tag:atomactivity.example.com,2008:photo
-
-
- Geraldine's Photos
-
-
-
-
-
- <p>Geraldine posted a Photo on PhotoPanic</p>
- <img src="/geraldine/photo1.jpg">
-
-
-EXAMPLE2;
-
-$_example3 = <<
-
-
-
- Example Feed
- A subtitle.
-
-
- urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6
- 2003-12-13T18:30:02Z
-
- John Doe
- johndoe@example.com
-
-
-
- Atom-Powered Robots Run Amok
-
-
-
- urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a
- 2003-12-13T18:30:02Z
- Some text.
-
-
-
-EXAMPLE3;
-
-$_example4 = <<
-
- @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
-
- spock
- http://example.net/user/2
-
-
- http://activitystrea.ms/schema/1.0/person
- http://example.net/user/2
- spock
-
-
-
- http://example.net/notice/14
- 2010-02-19T02:52:38+00:00
- 2010-02-19T02:52:38+00:00
-
-
-
-
- @<span class="vcard"><a href="http://example.net/user/1" class="url"><span class="fn nickname">evan</span></a></span> now is the time for all good men to come to the aid of their country. #<span class="tag"><a href="http://example.net/tag/thetime" rel="tag">thetime</a></span>
-
-
-EXAMPLE4;
-
-$_example5 = <<
-
- 3
- testuser timeline
- Updates from testuser on Zach Dev!
- http://example.net/mysite/avatar/3-96-20100224004207.jpeg
- 2010-02-24T06:38:49+00:00
-
- testuser
- http://example.net/mysite/user/3
-
-
-
-
-
-
-
-
- http://activitystrea.ms/schema/1.0/person
- http://example.net/mysite/user/3
- Test User
-
-
- 37.7749295 -122.4194155
-
-testuser
-Test User
-Just another test user.
-
- San Francisco, CA
-
-
- homepage
- http://example.com/blog.html
- true
-
-
-
-
- Hey man, is that Freedom Code?! #freedom #hippy
- Hey man, is that Freedom Code?! #freedom #hippy
-
- testuser
- http://example.net/mysite/user/3
-
-
- http://activitystrea.ms/schema/1.0/person
- http://example.net/mysite/user/3
- Test User
-
-
- 37.7749295 -122.4194155
-
-testuser
-Test User
-Just another test user.
-
- San Francisco, CA
-
-
- homepage
- http://example.com/blog.html
- true
-
-
-
-
- http://example.net/mysite/notice/7
- 2010-02-24T00:53:06+00:00
- 2010-02-24T00:53:06+00:00
-
- Hey man, is that Freedom Code?! #<span class="tag"><a href="http://example.net/mysite/tag/freedom" rel="tag">freedom</a></span> #<span class="tag"><a href="http://example.net/mysite/tag/hippy" rel="tag">hippy</a></span>
- 37.8313160 -122.2852473
-
-
-
-EXAMPLE5;
-
-$_example6 = <<
-
-
-
- WordPress.com News
-
- http://en.blog.wordpress.com
- The latest news on WordPress.com and the WordPress community.
- Thu, 18 Mar 2010 23:25:35 +0000
-
- http://wordpress.com/
- en
- hourly
- 1
-
-
- http://www.gravatar.com/blavatar/e6392390e3bcfadff3671c5a5653d95b?s=96&d=http://s2.wp.com/i/buttonw-com.png
- WordPress.com News
- http://en.blog.wordpress.com
-
-
-
-
- -
-
Rub-a-Dub-Dub in the PubSubHubbub
- http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/
- http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/#comments
- Wed, 03 Mar 2010 16:48:12 +0000
- Joseph Scott
-
-
-
-
-
-
- http://en.blog.wordpress.com/?p=3857
- ]]>
- From the tongue twisting name department we welcome PubSubHubbub, or as some people have shortened it to: PuSH. Like rssCloud , PuSH is a way for services that subscribe to updates from your blog to get updates even faster. In a nutshell, instead of having to periodically ask your blog if there are any updates they can now register to automatically receive updates each time you publish new content. In most cases these updates are sent out within a second or two of when you hit the publish button.
- Today we’ve turned on PuSH support for the more than 10.5 million blogs on WordPress.com. There’s nothing to configure, it’s working right now behind the scenes to help others keep up to date with your posts.
- For those using the WordPress.org software we are releasing a new PuSH plugin: PuSHPress . This plugin differs from the current PuSH related plugins by including a built-in hub.
- ]]>
- http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/feed/
-
- 96
-
-
- josephscott
-
-
-
-
-EXAMPLE6;
-
-$_example7 = <<
-
-
- evanpro's posterous
- http://evanpro.posterous.com
- Most recent posts at evanpro's posterous
- posterous.com
-
-
-
- -
-
Sat, 20 Mar 2010 07:32:31 -0700
- Checking out captain bones
- http://evanpro.posterous.com/checking-out-captain-bones
- http://evanpro.posterous.com/checking-out-captain-bones
-
-
- Bones!
-
-
-
- Permalink
-
- | Leave a comment »
-
-
]]>
-
-
- http://files.posterous.com/user_profile_pics/480326/2009-08-05-142447.jpg
- http://posterous.com/people/3sDslhaepotz
- Evan
- Prodromou
- evanpro
- Evan Prodromou
-
-
-
-
-EXAMPLE7;
-
-$_example8 = <<
-
-
- Activity Stream for: zcopley
- http://cliqset.com/feed/atom?uid=zcopley
-
- 0
- http://activitystrea.ms/schema/1.0/post
- 2010-03-22T01:35:53.000Z
-
- flickr
- http://flickr.com
- http://cliqset-services.s3.amazonaws.com/flickr.png
-
-
- http://activitystrea.ms/schema/1.0/photo
- IMG_1368
-
-
-
-
- http://activitystrea.ms/schema/1.0/photo
- IMG_1365
-
-
-
-
- http://activitystrea.ms/schema/1.0/photo
- Classic
-
-
- -Powered by pikchur.com/n0u
-
-
- http://activitystrea.ms/schema/1.0/photo
- IMG_1363
-
-
-
-
- http://activitystrea.ms/schema/1.0/photo
- IMG_1361
-
-
-
- zcopley posted some photos on Flickr
- zcopley posted 5 photos on Flickr
-
- 2010-03-22T20:46:42.778Z
- tag:cliqset.com,2010-03-22:/user/zcopley/SVgAZubGhtAnSAee
-
-
- zcopley
- http://cliqset.com/user/zcopley
-
-
- http://activitystrea.ms/schema/1.0/person
- zcopley
-
- Zach
- Copley
-
-
-
-
-
-
-
-EXAMPLE8;
-
-$_example9 = <<
-
-
-
- Test
- 2010-03-22T01:55:53.596Z
- test53725745374
- test
-
- Buzz by Zach Copley from Flickr
- IMG_1366
- 2010-03-18T04:29:23.000Z
- 2010-03-18T05:14:03.325Z
- test53725745374entry
-
-
- Zach Copley
- https://mywebsite.net/profiles/zcopley
-
- <div>IMG_1366</div>
-
-
- IMG_1366
-
-
-
-
- IMG_1365
-
-
- http://activitystrea.ms/schema/1.0/post
-
- http://activitystrea.ms/schema/1.0/photo
- test53725745374entry
- Buzz by Zach Copley from Flickr
- <div>IMG_1366</div>
-
-
-
-
- 0
-
-
-EXAMPLE9;
-
-// Sample PuSH entry from a group feed in 0.9.7
-// Old has been removed from entries in this version.
-// A bug in the order of input processing meant that we were incorrectly
-// reading the feed's instead of the entry's ,
-// causing the entry to get rejected as malformed (groups can't post on
-// their own; we want to see the actual author's info here).
-$_example10 = <<
-
- StatusNet
- http://lazarus.local/mublog/api/statusnet/groups/timeline/22.atom
- grouptest316173 timeline
- Updates from grouptest316173 on Blaguette!
- http://lazarus.local/mublog/theme/default/default-avatar-profile.png
- 2011-01-06T22:44:18+00:00
-
- http://activitystrea.ms/schema/1.0/group
- http://lazarus.local/mublog/group/22/id
- grouptest316173
-
-
-
-
- grouptest316173
- grouptest316173
-
-
- http://activitystrea.ms/schema/1.0/group
- http://lazarus.local/mublog/group/22/id
- grouptest316173
-
-
-
-
- grouptest316173
- grouptest316173
-
-
-
-
-
-
-
-
-
- http://activitystrea.ms/schema/1.0/note
- http://lazarus.local/mublog/notice/1243
- Group post from local to !grouptest316173, should go out over push.
- Group post from local to !<span class="vcard"><a href="http://lazarus.local/mublog/group/22/id" class="url"><span class="fn nickname">grouptest316173</span></a></span>, should go out over push.
-
- http://activitystrea.ms/schema/1.0/post
- 2011-01-06T22:44:18+00:00
- 2011-01-06T22:44:18+00:00
-
- http://activitystrea.ms/schema/1.0/person
- http://lazarus.local/mublog/user/557
- Pubtest316173 Smith
-
-
-
-
- pubtest316173
- Pubtest316173 Smith
- Stub account for OStatus tests.
-
- homepage
- http://example.org/pubtest316173
- true
-
-
-
-
-
-
- http://lazarus.local/mublog/api/statuses/user_timeline/557.atom
- Pubtest316173 Smith
-
-
-
- http://lazarus.local/mublog/theme/default/default-avatar-profile.png
- 2011-01-06T22:44:18+00:00
-
-
-
-
-
-
-EXAMPLE10;
-
-$_example11 = <<
-
- StatusNet
- http://freelish.us/api/statuses/user_timeline/1.atom
- demon timeline
- Updates from demon on freelish.us!
- http://avatar.status.net/f/freelishus/1-96-20110331163048.jpeg
- 2011-05-30T09:36:03-04:00
-
- http://activitystrea.ms/schema/1.0/person
- http://freelishus.status.net/user/1
- demon
-
-
-
-
-
- 45.50884 -73.58781
- demon
- Evan Prodromou
- Montreal hacker and entrepreneur.
-
- Montreal, Quebec
-
-
-
- homepage
- http://evan.status.net/
- true
-
-
-
-
-
- http://activitystrea.ms/schema/1.0/person
- http://freelishus.status.net/user/1
- Evan Prodromou
-
-
-
-
-
- 45.50884 -73.58781
- demon
- Evan Prodromou
- Montreal hacker and entrepreneur.
-
- Montreal, Quebec
-
-
-
- homepage
- http://evan.status.net/
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
- http://activitystrea.ms/schema/1.0/bookmark
- http://freelish.us/bookmark/9e930c3e-7ed9-47de-aba5-df6c60cec542
- Why you should build an open-source startup | Teambox Blog
-
-
- http://activitystrea.ms/schema/1.0/post
- 2011-05-26T20:36:25+00:00
- 2011-05-26T20:36:25+00:00
-
-
-
-
-
-
-
-
-
-EXAMPLE11;
diff --git a/tests/CommandInterperterTest.php b/tests/CommandInterperterTest.php
deleted file mode 100644
index 5f681ae1da..0000000000
--- a/tests/CommandInterperterTest.php
+++ /dev/null
@@ -1,171 +0,0 @@
-handle_command(null, $input);
-
- $type = $cmd ? get_class($cmd) : null;
- $this->assertEquals(strtolower($expectedType), strtolower($type), $comment);
- }
-
- static public function commandInterpreterCases()
- {
- $sets = array(
- array('help', 'HelpCommand'),
- array('help me bro', null, 'help does not accept multiple params'),
- array('HeLP', 'HelpCommand', 'case check'),
- array('HeLP Me BRO!', null, 'case & non-params check'),
-
- array('login', 'LoginCommand'),
- array('login to savings!', null, 'login does not accept params'),
-
- array('lose', null, 'lose must have at least 1 parameter'),
- array('lose foobar', 'LoseCommand', 'lose requires 1 parameter'),
- array('lose foobar', 'LoseCommand', 'check for space norm'),
- array('lose more weight', null, 'lose does not accept multiple params'),
-
- array('subscribers', 'SubscribersCommand'),
- array('subscribers foo', null, 'subscribers does not take params'),
-
- array('subscriptions', 'SubscriptionsCommand'),
- array('subscriptions foo', null, 'subscriptions does not take params'),
-
- array('groups', 'GroupsCommand'),
- array('groups foo', null, 'groups does not take params'),
-
- array('off', 'OffCommand', 'off accepts 0 or 1 params'),
- array('off foo', 'OffCommand', 'off accepts 0 or 1 params'),
- array('off foo bar', null, 'off accepts 0 or 1 params'),
-
- array('stop', 'OffCommand', 'stop accepts 0 params'),
- array('stop foo', null, 'stop accepts 0 params'),
-
- array('quit', 'OffCommand', 'quit accepts 0 params'),
- array('quit foo', null, 'quit accepts 0 params'),
-
- array('on', 'OnCommand', 'on accepts 0 or 1 params'),
- array('on foo', 'OnCommand', 'on accepts 0 or 1 params'),
- array('on foo bar', null, 'on accepts 0 or 1 params'),
-
- array('join', null),
- array('join foo', 'JoinCommand'),
- array('join foo bar', null),
-
- array('drop', null),
- array('drop foo', 'DropCommand'),
- array('drop foo bar', null),
-
- array('follow', null),
- array('follow foo', 'SubCommand'),
- array('follow foo bar', null),
-
- array('sub', null),
- array('sub foo', 'SubCommand'),
- array('sub foo bar', null),
-
- array('leave', null),
- array('leave foo', 'UnsubCommand'),
- array('leave foo bar', null),
-
- array('unsub', null),
- array('unsub foo', 'UnsubCommand'),
- array('unsub foo bar', null),
-
- array('leave', null),
- array('leave foo', 'UnsubCommand'),
- array('leave foo bar', null),
-
- array('d', null),
- array('d foo', null),
- array('d foo bar', 'MessageCommand'),
-
- array('dm', null),
- array('dm foo', null),
- array('dm foo bar', 'MessageCommand'),
-
- array('r', null),
- array('r foo', null),
- array('r foo bar', 'ReplyCommand'),
-
- array('reply', null),
- array('reply foo', null),
- array('reply foo bar', 'ReplyCommand'),
-
- array('repeat', null),
- array('repeat foo', 'RepeatCommand'),
- array('repeat foo bar', null),
-
- array('rp', null),
- array('rp foo', 'RepeatCommand'),
- array('rp foo bar', null),
-
- array('rt', null),
- array('rt foo', 'RepeatCommand'),
- array('rt foo bar', null),
-
- array('rd', null),
- array('rd foo', 'RepeatCommand'),
- array('rd foo bar', null),
-
- array('whois', null),
- array('whois foo', 'WhoisCommand'),
- array('whois foo bar', null),
-
-/* array('fav', null),
- array('fav foo', 'FavCommand'),
- array('fav foo bar', null),*/
-
- array('nudge', null),
- array('nudge foo', 'NudgeCommand'),
- array('nudge foo bar', null),
-
- array('stats', 'StatsCommand'),
- array('stats foo', null),
-
- array('invite', null),
- array('invite foo', 'InviteCommand'),
- array('invite foo bar', null),
-
- array('track', null),
- array('track foo', 'SearchSubTrackCommand'),
- array('track off', 'SearchSubTrackOffCommand'),
- array('track foo bar', null),
- array('track off foo', null),
-
- array('untrack', null),
- array('untrack foo', 'SearchSubUntrackCommand'),
- array('untrack all', 'SearchSubTrackOffCommand'),
- array('untrack foo bar', null),
- array('untrack all foo', null),
-
- array('tracking', 'SearchSubTrackingCommand'),
- array('tracking foo', null),
-
- array('tracks', 'SearchSubTrackingCommand'),
- array('tracks foo', null),
-
- );
- return $sets;
- }
-
-}
-
diff --git a/tests/Core/ActivityGenerationTests.php b/tests/Core/ActivityGenerationTests.php
new file mode 100644
index 0000000000..f8bb0257a0
--- /dev/null
+++ b/tests/Core/ActivityGenerationTests.php
@@ -0,0 +1,598 @@
+.
+
+namespace Tests\Unit;
+
+if (!defined('INSTALLDIR')) {
+ define('INSTALLDIR', dirname(dirname(__DIR__)));
+}
+if (!defined('PUBLICDIR')) {
+ define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
+}
+if (!defined('GNUSOCIAL')) {
+ define('GNUSOCIAL', true);
+}
+if (!defined('STATUSNET')) { // Compatibility
+ define('STATUSNET', true);
+}
+
+use Activity;
+use ActivityObject;
+use ActivityUtils;
+use ActivityVerb;
+use Conversation;
+use DOMDocument;
+use Exception;
+use Notice;
+use PHPUnit\Framework\TestCase;
+use User;
+use User_group;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class ActivityGenerationTests extends TestCase
+{
+ static $author1 = null;
+ static $author2 = null;
+
+ static $targetUser1 = null;
+ static $targetUser2 = null;
+
+ static $targetGroup1 = null;
+ static $targetGroup2 = null;
+
+ public static function setUpBeforeClass()
+ {
+ $authorNick1 = 'activitygenerationtestsuser' . common_random_hexstr(4);
+ $authorNick2 = 'activitygenerationtestsuser' . common_random_hexstr(4);
+
+ $targetNick1 = 'activitygenerationteststarget' . common_random_hexstr(4);
+ $targetNick2 = 'activitygenerationteststarget' . common_random_hexstr(4);
+
+ $groupNick1 = 'activitygenerationtestsgroup' . common_random_hexstr(4);
+ $groupNick2 = 'activitygenerationtestsgroup' . common_random_hexstr(4);
+
+ try {
+ self::$author1 = User::register(array('nickname' => $authorNick1,
+ 'email' => $authorNick1 . '@example.net',
+ 'email_confirmed' => true));
+
+ self::$author2 = User::register(array('nickname' => $authorNick2,
+ 'email' => $authorNick2 . '@example.net',
+ 'email_confirmed' => true));
+
+ self::$targetUser1 = User::register(array('nickname' => $targetNick1,
+ 'email' => $targetNick1 . '@example.net',
+ 'email_confirmed' => true));
+
+ self::$targetUser2 = User::register(array('nickname' => $targetNick2,
+ 'email' => $targetNick2 . '@example.net',
+ 'email_confirmed' => true));
+
+ self::$targetGroup1 = User_group::register(array('nickname' => $groupNick1,
+ 'userid' => self::$author1->id,
+ 'aliases' => array(),
+ 'local' => true,
+ 'location' => null,
+ 'description' => null,
+ 'fullname' => null,
+ 'homepage' => null,
+ 'mainpage' => null));
+ self::$targetGroup2 = User_group::register(array('nickname' => $groupNick2,
+ 'userid' => self::$author1->id,
+ 'aliases' => array(),
+ 'local' => true,
+ 'location' => null,
+ 'description' => null,
+ 'fullname' => null,
+ 'homepage' => null,
+ 'mainpage' => null));
+ } catch (Exception $e) {
+ self::tearDownAfterClass();
+ throw $e;
+ }
+ }
+
+ public function testBasicNoticeActivity()
+ {
+ $notice = $this->_fakeNotice();
+
+ $entry = $notice->asAtomEntry(true);
+
+ $element = $this->_entryToElement($entry, false);
+
+ $this->assertEquals($notice->getUri(), ActivityUtils::childContent($element, 'id'));
+ $this->assertEquals('New note by ' . self::$author1->nickname, ActivityUtils::childContent($element, 'title'));
+ $this->assertEquals($notice->rendered, ActivityUtils::childContent($element, 'content'));
+ $this->assertEquals(strtotime($notice->created), strtotime(ActivityUtils::childContent($element, 'published')));
+ $this->assertEquals(strtotime($notice->created), strtotime(ActivityUtils::childContent($element, 'updated')));
+ $this->assertEquals(ActivityVerb::POST, ActivityUtils::childContent($element, 'verb', Activity::SPEC));
+ $this->assertEquals(ActivityObject::NOTE, ActivityUtils::childContent($element, 'object-type', Activity::SPEC));
+ }
+
+ public function testNamespaceFlag()
+ {
+ $notice = $this->_fakeNotice();
+
+ $entry = $notice->asAtomEntry(true);
+
+ $element = $this->_entryToElement($entry, false);
+
+ $this->assertTrue($element->hasAttribute('xmlns'));
+ $this->assertTrue($element->hasAttribute('xmlns:thr'));
+ $this->assertTrue($element->hasAttribute('xmlns:georss'));
+ $this->assertTrue($element->hasAttribute('xmlns:activity'));
+ $this->assertTrue($element->hasAttribute('xmlns:media'));
+ $this->assertTrue($element->hasAttribute('xmlns:poco'));
+ $this->assertTrue($element->hasAttribute('xmlns:ostatus'));
+ $this->assertTrue($element->hasAttribute('xmlns:statusnet'));
+
+ $entry = $notice->asAtomEntry(false);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $this->assertFalse($element->hasAttribute('xmlns'));
+ $this->assertFalse($element->hasAttribute('xmlns:thr'));
+ $this->assertFalse($element->hasAttribute('xmlns:georss'));
+ $this->assertFalse($element->hasAttribute('xmlns:activity'));
+ $this->assertFalse($element->hasAttribute('xmlns:media'));
+ $this->assertFalse($element->hasAttribute('xmlns:poco'));
+ $this->assertFalse($element->hasAttribute('xmlns:ostatus'));
+ $this->assertFalse($element->hasAttribute('xmlns:statusnet'));
+ }
+
+ public function testSourceFlag()
+ {
+ $notice = $this->_fakeNotice();
+
+ // Test with no source
+
+ $entry = $notice->asAtomEntry(false, false);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $source = ActivityUtils::child($element, 'source');
+
+ $this->assertNull($source);
+
+ // Test with source
+
+ $entry = $notice->asAtomEntry(false, true);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $source = ActivityUtils::child($element, 'source');
+
+ $this->assertNotNull($source);
+ }
+
+ public function testSourceContent()
+ {
+ $notice = $this->_fakeNotice();
+ // make a time difference!
+ sleep(2);
+ $notice2 = $this->_fakeNotice();
+
+ $entry = $notice->asAtomEntry(false, true);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $source = ActivityUtils::child($element, 'source');
+
+ $atomUrl = common_local_url('ApiTimelineUser', array('id' => self::$author1->id, 'format' => 'atom'));
+
+ $profile = self::$author1->getProfile();
+
+ $this->assertEquals($atomUrl, ActivityUtils::childContent($source, 'id'));
+ $this->assertEquals($atomUrl, ActivityUtils::getLink($source, 'self', 'application/atom+xml'));
+ $this->assertEquals($profile->profileurl, ActivityUtils::getPermalink($source));
+ $this->assertEquals(strtotime($notice2->created), strtotime(ActivityUtils::childContent($source, 'updated')));
+ // XXX: do we care here?
+ $this->assertFalse(is_null(ActivityUtils::childContent($source, 'title')));
+ $this->assertEquals(common_config('license', 'url'), ActivityUtils::getLink($source, 'license'));
+ }
+
+ public function testAuthorFlag()
+ {
+ $notice = $this->_fakeNotice();
+
+ // Test with no author
+
+ $entry = $notice->asAtomEntry(false, false, false);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $this->assertNull(ActivityUtils::child($element, 'author'));
+ $this->assertNull(ActivityUtils::child($element, 'actor', Activity::SPEC));
+
+ // Test with source
+
+ $entry = $notice->asAtomEntry(false, false, true);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $author = ActivityUtils::child($element, 'author');
+ $actor = ActivityUtils::child($element, 'actor', Activity::SPEC);
+
+ $this->assertFalse(is_null($author));
+ $this->assertTrue(is_null($actor)); // is obsolete, no longer added
+ }
+
+ public function testAuthorContent()
+ {
+ $notice = $this->_fakeNotice();
+
+ // Test with author
+
+ $entry = $notice->asAtomEntry(false, false, true);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $author = ActivityUtils::child($element, 'author');
+
+ $this->assertEquals(self::$author1->getNickname(), ActivityUtils::childContent($author, 'name'));
+ $this->assertEquals(self::$author1->getUri(), ActivityUtils::childContent($author, 'uri'));
+ }
+
+ /**
+ * We no longer create entries, they have merged to
+ */
+ public function testActorContent()
+ {
+ $notice = $this->_fakeNotice();
+
+ // Test with author
+
+ $entry = $notice->asAtomEntry(false, false, true);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $actor = ActivityUtils::child($element, 'actor', Activity::SPEC);
+
+ $this->assertEquals($actor, null);
+ }
+
+ public function testReplyLink()
+ {
+ $orig = $this->_fakeNotice(self::$targetUser1);
+
+ $text = "@" . self::$targetUser1->nickname . " reply text " . common_random_hexstr(4);
+
+ $reply = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
+
+ $entry = $reply->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $irt = ActivityUtils::child($element, 'in-reply-to', 'http://purl.org/syndication/thread/1.0');
+
+ $this->assertNotNull($irt);
+ $this->assertEquals($orig->getUri(), $irt->getAttribute('ref'));
+ $this->assertEquals($orig->getUrl(), $irt->getAttribute('href'));
+ }
+
+ public function testReplyAttention()
+ {
+ $orig = $this->_fakeNotice(self::$targetUser1);
+
+ $text = "@" . self::$targetUser1->nickname . " reply text " . common_random_hexstr(4);
+
+ $reply = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
+
+ $entry = $reply->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $this->assertEquals(self::$targetUser1->getUri(), ActivityUtils::getLink($element, 'mentioned'));
+ }
+
+ public function testMultipleReplyAttention()
+ {
+ $orig = $this->_fakeNotice(self::$targetUser1);
+
+ $text = "@" . self::$targetUser1->nickname . " reply text " . common_random_hexstr(4);
+
+ $reply = Notice::saveNew(self::$targetUser2->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
+
+ $text = "@" . self::$targetUser1->nickname . " @" . self::$targetUser2->nickname . " reply text " . common_random_hexstr(4);
+
+ $reply2 = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null, 'reply_to' => $reply->id));
+
+ $entry = $reply2->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $links = ActivityUtils::getLinks($element, 'mentioned');
+
+ $hrefs = array();
+
+ foreach ($links as $link) {
+ $hrefs[] = $link->getAttribute('href');
+ }
+
+ $this->assertTrue(in_array(self::$targetUser1->getUri(), $hrefs));
+ $this->assertTrue(in_array(self::$targetUser2->getUri(), $hrefs));
+ }
+
+ public function testGroupPostAttention()
+ {
+ $text = "!" . self::$targetGroup1->nickname . " reply text " . common_random_hexstr(4);
+
+ $notice = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null));
+
+ $entry = $notice->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $this->assertEquals(self::$targetGroup1->getUri(), ActivityUtils::getLink($element, 'mentioned'));
+ }
+
+ public function testMultipleGroupPostAttention()
+ {
+ $text = "!" . self::$targetGroup1->nickname . " !" . self::$targetGroup2->nickname . " reply text " . common_random_hexstr(4);
+
+ $notice = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null));
+
+ $entry = $notice->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $links = ActivityUtils::getLinks($element, 'mentioned');
+
+ $hrefs = array();
+
+ foreach ($links as $link) {
+ $hrefs[] = $link->getAttribute('href');
+ }
+
+ $this->assertTrue(in_array(self::$targetGroup1->getUri(), $hrefs));
+ $this->assertTrue(in_array(self::$targetGroup2->getUri(), $hrefs));
+
+ }
+
+ public function testRepeatLink()
+ {
+ $notice = $this->_fakeNotice(self::$author1);
+ $repeat = $notice->repeat(self::$author2->getProfile(), 'test');
+
+ $entry = $repeat->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $noticeInfo = ActivityUtils::child($element, 'notice_info', 'http://status.net/schema/api/1/');
+
+ $this->assertNotNull($noticeInfo);
+ $this->assertEquals($notice->id, $noticeInfo->getAttribute('repeat_of'));
+ $this->assertEquals($repeat->id, $noticeInfo->getAttribute('local_id'));
+ }
+
+ public function testTag()
+ {
+ $tag1 = common_random_hexstr(4);
+
+ $notice = $this->_fakeNotice(self::$author1, '#' . $tag1);
+
+ $entry = $notice->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $category = ActivityUtils::child($element, 'category');
+
+ $this->assertNotNull($category);
+ $this->assertEquals($tag1, $category->getAttribute('term'));
+ }
+
+ public function testMultiTag()
+ {
+ $tag1 = common_random_hexstr(4);
+ $tag2 = common_random_hexstr(4);
+
+ $notice = $this->_fakeNotice(self::$author1, '#' . $tag1 . ' #' . $tag2);
+
+ $entry = $notice->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $categories = $element->getElementsByTagName('category');
+
+ $this->assertNotNull($categories);
+ $this->assertEquals(2, $categories->length);
+
+ $terms = array();
+
+ for ($i = 0; $i < $categories->length; $i++) {
+ $cat = $categories->item($i);
+ $terms[] = $cat->getAttribute('term');
+ }
+
+ $this->assertTrue(in_array($tag1, $terms));
+ $this->assertTrue(in_array($tag2, $terms));
+ }
+
+ public function testGeotaggedActivity()
+ {
+ $notice = Notice::saveNew(self::$author1->id, common_random_hexstr(4), 'test', array('uri' => null, 'lat' => 45.5, 'lon' => -73.6));
+
+ $entry = $notice->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $this->assertEquals('45.5000000 -73.6000000', ActivityUtils::childContent($element, 'point', "http://www.georss.org/georss"));
+ }
+
+ public function testNoticeInfo()
+ {
+ $notice = $this->_fakeNotice();
+
+ $entry = $notice->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
+
+ $this->assertEquals($notice->id, $noticeInfo->getAttribute('local_id'));
+ $this->assertEquals($notice->source, $noticeInfo->getAttribute('source'));
+ $this->assertEquals('', $noticeInfo->getAttribute('repeat_of'));
+ $this->assertEquals('', $noticeInfo->getAttribute('repeated'));
+// $this->assertEquals('', $noticeInfo->getAttribute('favorite'));
+ $this->assertEquals('', $noticeInfo->getAttribute('source_link'));
+ }
+
+ public function testNoticeInfoRepeatOf()
+ {
+ $notice = $this->_fakeNotice();
+
+ $repeat = $notice->repeat(self::$author2->getProfile(), 'test');
+
+ $entry = $repeat->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
+
+ $this->assertEquals($notice->id, $noticeInfo->getAttribute('repeat_of'));
+ }
+
+ public function testNoticeInfoRepeated()
+ {
+ $notice = $this->_fakeNotice();
+
+ $repeat = $notice->repeat(self::$author2->getProfile(), 'test');
+
+ $entry = $notice->asAtomEntry(false, false, false, self::$author2->getProfile());
+
+ $element = $this->_entryToElement($entry, true);
+
+ $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
+
+ $this->assertEquals('true', $noticeInfo->getAttribute('repeated'));
+
+ $entry = $notice->asAtomEntry(false, false, false, self::$targetUser1->getProfile());
+
+ $element = $this->_entryToElement($entry, true);
+
+ $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
+
+ $this->assertEquals('false', $noticeInfo->getAttribute('repeated'));
+ }
+
+ /* public function testNoticeInfoFave()
+ {
+ $notice = $this->_fakeNotice();
+
+ $fave = Fave::addNew(self::$author2->getProfile(), $notice);
+
+ // Should be set if user has faved
+
+ $entry = $notice->asAtomEntry(false, false, false, self::$author2);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
+
+ $this->assertEquals('true', $noticeInfo->getAttribute('favorite'));
+
+ // Shouldn't be set if user has not faved
+
+ $entry = $notice->asAtomEntry(false, false, false, self::$targetUser1);
+
+ $element = $this->_entryToElement($entry, true);
+
+ $noticeInfo = ActivityUtils::child($element, 'notice_info', "http://status.net/schema/api/1/");
+
+ $this->assertEquals('false', $noticeInfo->getAttribute('favorite'));
+ }*/
+
+ public function testConversationLink()
+ {
+ $orig = $this->_fakeNotice(self::$targetUser1);
+
+ $text = "@" . self::$targetUser1->nickname . " reply text " . common_random_hexstr(4);
+
+ $reply = Notice::saveNew(self::$author1->id, $text, 'test', array('uri' => null, 'reply_to' => $orig->id));
+
+ $conv = Conversation::getKV('id', $reply->conversation);
+
+ $entry = $reply->asAtomEntry();
+
+ $element = $this->_entryToElement($entry, true);
+
+ $this->assertEquals($conv->getUrl(), ActivityUtils::getLink($element, 'ostatus:conversation'));
+ }
+
+ public static function tearDownAfterClass()
+ {
+ if (!is_null(self::$author1)) {
+ self::$author1->getProfile()->delete();
+ }
+
+ if (!is_null(self::$author2)) {
+ self::$author2->getProfile()->delete();
+ }
+
+ if (!is_null(self::$targetUser1)) {
+ self::$targetUser1->getProfile()->delete();
+ }
+
+ if (!is_null(self::$targetUser2)) {
+ self::$targetUser2->getProfile()->delete();
+ }
+
+ if (!is_null(self::$targetGroup1)) {
+ self::$targetGroup1->delete();
+ }
+
+ if (!is_null(self::$targetGroup2)) {
+ self::$targetGroup2->delete();
+ }
+ }
+
+ private function _fakeNotice($user = null, $text = null)
+ {
+ if (empty($user)) {
+ $user = self::$author1;
+ }
+
+ if (empty($text)) {
+ $text = "fake-o text-o " . common_random_hexstr(32);
+ }
+
+ return Notice::saveNew($user->id, $text, 'test', array('uri' => null));
+ }
+
+ private function _entryToElement($entry, $namespace = false)
+ {
+ $xml = '' . "\n\n";
+ $xml .= '' . "\n";
+ $doc = new DOMDocument();
+ $doc->loadXML($xml);
+ $feed = $doc->documentElement;
+ $entries = $feed->getElementsByTagName('entry');
+
+ return $entries->item(0);
+ }
+}
diff --git a/tests/Core/ActivityParseTests.php b/tests/Core/ActivityParseTests.php
new file mode 100644
index 0000000000..12e2f03ddb
--- /dev/null
+++ b/tests/Core/ActivityParseTests.php
@@ -0,0 +1,1080 @@
+.
+
+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 Activity;
+use ActivityObject;
+use ActivityUtils;
+use ActivityVerb;
+use DOMDocument;
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class ActivityParseTests extends TestCase
+{
+
+ public function testMastodonRetweet()
+ {
+ global $_mastodon_retweet;
+ $dom = new DOMDocument();
+ $dom->loadXML($_mastodon_retweet);
+ $feed = $dom->documentElement;
+ $entries = $feed->getElementsByTagName('entry');
+ $entry = $entries->item(0);
+ $act = new Activity($entry, $feed);
+ $this->assertFalse(empty($act));
+ $this->assertFalse(empty($act->objects[0]));
+
+ $object = $act->objects[0];
+ $this->assertEquals($object->verb, ActivityVerb::POST);
+ }
+
+ public function testGSReweet()
+ {
+ global $_gs_retweet;
+ $dom = new DOMDocument();
+ $dom->loadXML($_gs_retweet);
+ $feed = $dom->documentElement;
+ $entries = $feed->getElementsByTagName('entry');
+ $entry = $entries->item(0);
+ $act = new Activity($entry, $feed);
+ $this->assertFalse(empty($act));
+ $this->assertFalse(empty($act->objects[0]));
+
+ $object = $act->objects[0];
+ $this->assertEquals($object->verb, ActivityVerb::POST);
+ }
+
+ public function testExample1()
+ {
+ global $_example1;
+ $dom = new DOMDocument();
+ $dom->loadXML($_example1);
+ $act = new Activity($dom->documentElement);
+
+ $this->assertFalse(empty($act));
+
+ $this->assertEquals(1243860840, $act->time);
+ $this->assertEquals(ActivityVerb::POST, $act->verb);
+
+ $this->assertFalse(empty($act->objects[0]));
+ $this->assertEquals('Punctuation Changeset', $act->objects[0]->title);
+ $this->assertEquals('http://versioncentral.example.org/activity/changeset', $act->objects[0]->type);
+ $this->assertEquals('Fixing punctuation because it makes it more readable.', $act->objects[0]->summary);
+ $this->assertEquals('tag:versioncentral.example.org,2009:/change/1643245', $act->objects[0]->id);
+ }
+
+ public function testExample2()
+ {
+ global $_example2;
+ $dom = new DOMDocument();
+ $dom->loadXML($_example2);
+ $act = new Activity($dom->documentElement);
+
+ $this->assertFalse(empty($act));
+ // Did we handle correctly with a typical payload?
+ $this->assertEquals("Geraldine posted a Photo on PhotoPanic
\n " .
+ " ", trim($act->content));
+ }
+
+ public function testExample3()
+ {
+ global $_example3;
+ $dom = new DOMDocument();
+ $dom->loadXML($_example3);
+
+ $feed = $dom->documentElement;
+
+ $entries = $feed->getElementsByTagName('entry');
+
+ $entry = $entries->item(0);
+
+ $act = new Activity($entry, $feed);
+
+ $this->assertFalse(empty($act));
+ $this->assertEquals(1071340202, $act->time);
+ $this->assertEquals('http://example.org/2003/12/13/atom03.html', $act->link);
+
+ $this->assertEquals($act->verb, ActivityVerb::POST);
+
+ $this->assertFalse(empty($act->actor));
+ $this->assertEquals(ActivityObject::PERSON, $act->actor->type);
+ $this->assertEquals('John Doe', $act->actor->title);
+ $this->assertEquals('mailto:johndoe@example.com', $act->actor->id);
+
+ $this->assertFalse(empty($act->objects[0]));
+ $this->assertEquals(ActivityObject::NOTE, $act->objects[0]->type);
+ $this->assertEquals('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', $act->objects[0]->id);
+ $this->assertEquals('Atom-Powered Robots Run Amok', $act->objects[0]->title);
+ $this->assertEquals('Some text.', $act->objects[0]->summary);
+ $this->assertEquals('http://example.org/2003/12/13/atom03.html', $act->objects[0]->link);
+
+ $this->assertFalse(empty($act->context));
+
+ $this->assertTrue(empty($act->target));
+
+ $this->assertEquals($act->entry, $entry);
+ $this->assertEquals($act->feed, $feed);
+ }
+
+ public function testExample4()
+ {
+ global $_example4;
+ $dom = new DOMDocument();
+ $dom->loadXML($_example4);
+
+ $entry = $dom->documentElement;
+
+ $act = new Activity($entry);
+
+ $this->assertFalse(empty($act));
+ $this->assertEquals(1266547958, $act->time);
+ $this->assertEquals('http://example.net/notice/14', $act->link);
+
+ $this->assertFalse(empty($act->context));
+ $this->assertEquals('http://example.net/notice/12', $act->context->replyToID);
+ $this->assertEquals('http://example.net/notice/12', $act->context->replyToUrl);
+ $this->assertEquals('http://example.net/conversation/11', $act->context->conversation);
+ $this->assertEquals(array('http://example.net/user/1'), array_keys($act->context->attention));
+
+ $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 ');
+
+ $this->assertFalse(empty($act->actor));
+ }
+
+ public function testExample5()
+ {
+ global $_example5;
+ $dom = new DOMDocument();
+ $dom->loadXML($_example5);
+
+ $feed = $dom->documentElement;
+
+ // @todo Test feed elements
+
+ $entries = $feed->getElementsByTagName('entry');
+ $entry = $entries->item(0);
+
+ $act = new Activity($entry, $feed);
+
+ // Post
+ $this->assertEquals($act->verb, ActivityVerb::POST);
+ $this->assertFalse(empty($act->context));
+
+ // Actor w/Portable Contacts stuff
+ $this->assertFalse(empty($act->actor));
+ $this->assertEquals($act->actor->type, ActivityObject::PERSON);
+ $this->assertEquals($act->actor->title, 'Test User');
+ $this->assertEquals($act->actor->id, 'http://example.net/mysite/user/3');
+ $this->assertEquals($act->actor->link, 'http://example.net/mysite/testuser');
+
+ $avatars = $act->actor->avatarLinks;
+
+ $this->assertEquals(
+ $avatars[0]->url,
+ 'http://example.net/mysite/avatar/3-96-20100224004207.jpeg'
+ );
+
+ $this->assertEquals($act->actor->displayName, 'Test User');
+
+ $poco = $act->actor->poco;
+ $this->assertEquals($poco->preferredUsername, 'testuser');
+ $this->assertEquals($poco->address->formatted, 'San Francisco, CA');
+ $this->assertEquals($poco->urls[0]->type, 'homepage');
+ $this->assertEquals($poco->urls[0]->value, 'http://example.com/blog.html');
+ $this->assertEquals($poco->urls[0]->primary, 'true');
+ $this->assertEquals($act->actor->geopoint, '37.7749295 -122.4194155');
+ }
+
+ public function testExample6()
+ {
+ global $_example6;
+
+ $dom = new DOMDocument();
+ $dom->loadXML($_example6);
+
+ $rss = $dom->documentElement;
+
+ $channels = $dom->getElementsByTagName('channel');
+
+ $channel = $channels->item(0);
+
+ $items = $channel->getElementsByTagName('item');
+
+ $item = $items->item(0);
+
+ $act = new Activity($item, $channel);
+
+ $this->assertEquals($act->verb, ActivityVerb::POST);
+
+ $this->assertEquals($act->id, 'http://en.blog.wordpress.com/?p=3857');
+ $this->assertEquals($act->link, 'http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/');
+ $this->assertEquals($act->title, 'Rub-a-Dub-Dub in the PubSubHubbub');
+ $this->assertEquals($act->time, 1267634892);
+
+ $actor = $act->actor;
+
+ $this->assertFalse(empty($actor));
+ $this->assertEquals($actor->title, "Joseph Scott");
+ }
+
+ public function testExample7()
+ {
+ global $_example7;
+
+ $dom = new DOMDocument();
+ $dom->loadXML($_example7);
+
+ $rss = $dom->documentElement;
+
+ $channels = $dom->getElementsByTagName('channel');
+
+ $channel = $channels->item(0);
+
+ $items = $channel->getElementsByTagName('item');
+
+ $item = $items->item(0);
+
+ $act = new Activity($item, $channel);
+
+ $this->assertEquals(ActivityVerb::POST, $act->verb);
+ $this->assertEquals('http://evanpro.posterous.com/checking-out-captain-bones', $act->link);
+ $this->assertEquals('http://evanpro.posterous.com/checking-out-captain-bones', $act->id);
+ $this->assertEquals('Checking out captain bones', $act->title);
+ $this->assertEquals(1269095551, $act->time);
+
+ $actor = $act->actor;
+
+ $this->assertEquals(ActivityObject::PERSON, $actor->type);
+ $this->assertEquals('http://posterous.com/people/3sDslhaepotz', $actor->id);
+ $this->assertEquals('Evan Prodromou', $actor->title);
+ $this->assertNull($actor->summary);
+ $this->assertNull($actor->content);
+ $this->assertEquals('http://posterous.com/people/3sDslhaepotz', $actor->link);
+ $this->assertNull($actor->source);
+ $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);
+ $this->assertNotNull($actor->poco);
+ $this->assertEquals('evanpro', $actor->poco->preferredUsername);
+ $this->assertEquals('Evan Prodromou', $actor->poco->displayName);
+ $this->assertNull($actor->poco->note);
+ $this->assertNull($actor->poco->address);
+ $this->assertEquals(0, count($actor->poco->urls));
+ }
+
+ // Media test - cliqset
+ public function testExample8()
+ {
+ global $_example8;
+ $dom = new DOMDocument();
+ $dom->loadXML($_example8);
+
+ $feed = $dom->documentElement;
+
+ $entries = $feed->getElementsByTagName('entry');
+
+ $entry = $entries->item(0);
+
+ $act = new Activity($entry, $feed);
+
+ $this->assertFalse(empty($act));
+ $this->assertEquals($act->time, 1269221753);
+ $this->assertEquals($act->verb, ActivityVerb::POST);
+ $this->assertEquals($act->summary, 'zcopley posted 5 photos on Flickr');
+
+ $this->assertFalse(empty($act->objects));
+ $this->assertEquals(sizeof($act->objects), 5);
+
+ $this->assertEquals($act->objects[0]->type, ActivityObject::PHOTO);
+ $this->assertEquals($act->objects[0]->title, 'IMG_1368');
+ $this->assertNull($act->objects[0]->description);
+ $this->assertEquals(
+ $act->objects[0]->thumbnail,
+ 'http://media.cliqset.com/6f6fbee9d7dfbffc73b6ef626275eb5f_thumb.jpg'
+ );
+ $this->assertEquals(
+ $act->objects[0]->link,
+ 'http://www.flickr.com/photos/zcopley/4452933806/'
+ );
+
+ $this->assertEquals($act->objects[1]->type, ActivityObject::PHOTO);
+ $this->assertEquals($act->objects[1]->title, 'IMG_1365');
+ $this->assertNull($act->objects[1]->description);
+ $this->assertEquals(
+ $act->objects[1]->thumbnail,
+ 'http://media.cliqset.com/b8f3932cd0bba1b27f7c8b3ef986915e_thumb.jpg'
+ );
+ $this->assertEquals(
+ $act->objects[1]->link,
+ 'http://www.flickr.com/photos/zcopley/4442630390/'
+ );
+
+ $this->assertEquals($act->objects[2]->type, ActivityObject::PHOTO);
+ $this->assertEquals($act->objects[2]->title, 'Classic');
+ $this->assertEquals(
+ $act->objects[2]->description,
+ '-Powered by pikchur.com/n0u'
+ );
+ $this->assertEquals(
+ $act->objects[2]->thumbnail,
+ 'http://media.cliqset.com/fc54c15f850b7a9a8efa644087a48c91_thumb.jpg'
+ );
+ $this->assertEquals(
+ $act->objects[2]->link,
+ 'http://www.flickr.com/photos/zcopley/4430754103/'
+ );
+
+ $this->assertEquals($act->objects[3]->type, ActivityObject::PHOTO);
+ $this->assertEquals($act->objects[3]->title, 'IMG_1363');
+ $this->assertNull($act->objects[3]->description);
+
+ $this->assertEquals(
+ $act->objects[3]->thumbnail,
+ 'http://media.cliqset.com/4b1d307c9217e2114391a8b229d612cb_thumb.jpg'
+ );
+ $this->assertEquals(
+ $act->objects[3]->link,
+ 'http://www.flickr.com/photos/zcopley/4416969717/'
+ );
+
+ $this->assertEquals($act->objects[4]->type, ActivityObject::PHOTO);
+ $this->assertEquals($act->objects[4]->title, 'IMG_1361');
+ $this->assertNull($act->objects[4]->description);
+
+ $this->assertEquals(
+ $act->objects[4]->thumbnail,
+ 'http://media.cliqset.com/23d9b4b96b286e0347d36052f22f6e60_thumb.jpg'
+ );
+ $this->assertEquals(
+ $act->objects[4]->link,
+ 'http://www.flickr.com/photos/zcopley/4417734232/'
+ );
+
+ }
+
+ 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>"));
+ foreach ($tests as $data) {
+ list($source, $output) = $data;
+ $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));
+ $this->assertEquals($output, trim($act->content));
+ }
+ }
+
+ 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>"));
+ foreach ($tests as $data) {
+ list($source, $output) = $data;
+ $xml = "- " .
+ "
http://example.com/fakeid " .
+ "RSS content tests " .
+ $source .
+ " ";
+ $dom = new DOMDocument();
+ $dom->loadXML($xml);
+ $act = new Activity($dom->documentElement);
+
+ $this->assertFalse(empty($act));
+ $this->assertEquals($output, trim($act->content));
+ }
+ }
+
+ public function testExample10()
+ {
+ global $_example10;
+ $dom = new DOMDocument();
+ $dom->loadXML($_example10);
+
+ // example 10 is a PuSH item of a post on a group feed, as generated
+ // by 0.9.7 code after migration away from to
+ $feed = $dom->documentElement;
+ $entry = $dom->getElementsByTagName('entry')->item(0);
+ $expected = 'http://lazarus.local/mublog/user/557';
+
+ // Reading just the entry alone should pick up its own
+ // as the actor.
+ $act = new Activity($entry);
+ $this->assertEquals($act->actor->id, $expected);
+
+ // Reading the entry in feed context used to be buggy, picking up
+ // the feed's which referred to the group.
+ // It should now be returning the expected author entry...
+ $act = new Activity($entry, $feed);
+ $this->assertEquals($act->actor->id, $expected);
+ }
+
+ public function testBookmarkRelated()
+ {
+ global $_example11;
+ $dom = new DOMDocument();
+ $dom->loadXML($_example11);
+
+ $feed = $dom->documentElement;
+ $entry = $dom->getElementsByTagName('entry')->item(0);
+
+ $expected = 'http://blog.teambox.com/open-source-companies';
+
+ $links = ActivityUtils::getLinks($entry, 'related');
+
+ $this->assertFalse(empty($links));
+ $this->assertTrue(is_array($links));
+ $this->assertEquals(count($links), 1);
+
+ $url = $links[0]->getAttribute('href');
+
+ $this->assertEquals($url, $expected);
+ }
+}
+
+$_example1 = <<
+
+ tag:versioncentral.example.org,2009:/commit/1643245
+ 2009-06-01T12:54:00Z
+ Geraldine committed a change to yate
+ Geraldine just committed a change to yate on VersionCentral
+
+ http://activitystrea.ms/schema/1.0/post
+ http://versioncentral.example.org/activity/commit
+
+ http://versioncentral.example.org/activity/changeset
+ tag:versioncentral.example.org,2009:/change/1643245
+ Punctuation Changeset
+ Fixing punctuation because it makes it more readable.
+
+
+
+EXAMPLE1;
+
+$_example2 = <<
+
+ tag:photopanic.example.com,2008:activity01
+ Geraldine posted a Photo on PhotoPanic
+ 2008-11-02T15:29:00Z
+
+
+ http://activitystrea.ms/schema/1.0/post
+
+
+ tag:photopanic.example.com,2008:photo01
+ My Cat
+ 2008-11-02T15:29:00Z
+
+
+ tag:atomactivity.example.com,2008:photo
+
+
+ Geraldine's Photos
+
+
+
+
+
+ <p>Geraldine posted a Photo on PhotoPanic</p>
+ <img src="/geraldine/photo1.jpg">
+
+
+EXAMPLE2;
+
+$_example3 = <<
+
+
+
+ Example Feed
+ A subtitle.
+
+
+ urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6
+ 2003-12-13T18:30:02Z
+
+ John Doe
+ johndoe@example.com
+
+
+
+ Atom-Powered Robots Run Amok
+
+
+
+ urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a
+ 2003-12-13T18:30:02Z
+ Some text.
+
+
+
+EXAMPLE3;
+
+$_example4 = <<
+
+ @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
+
+ spock
+ http://example.net/user/2
+
+
+ http://activitystrea.ms/schema/1.0/person
+ http://example.net/user/2
+ spock
+
+
+
+ http://example.net/notice/14
+ 2010-02-19T02:52:38+00:00
+ 2010-02-19T02:52:38+00:00
+
+
+
+
+ @<span class="vcard"><a href="http://example.net/user/1" class="url"><span class="fn nickname">evan</span></a></span> now is the time for all good men to come to the aid of their country. #<span class="tag"><a href="http://example.net/tag/thetime" rel="tag">thetime</a></span>
+
+
+EXAMPLE4;
+
+$_example5 = <<
+
+ 3
+ testuser timeline
+ Updates from testuser on Zach Dev!
+ http://example.net/mysite/avatar/3-96-20100224004207.jpeg
+ 2010-02-24T06:38:49+00:00
+
+ testuser
+ http://example.net/mysite/user/3
+
+
+
+
+
+
+
+
+ http://activitystrea.ms/schema/1.0/person
+ http://example.net/mysite/user/3
+ Test User
+
+
+ 37.7749295 -122.4194155
+
+testuser
+Test User
+Just another test user.
+
+ San Francisco, CA
+
+
+ homepage
+ http://example.com/blog.html
+ true
+
+
+
+
+ Hey man, is that Freedom Code?! #freedom #hippy
+ Hey man, is that Freedom Code?! #freedom #hippy
+
+ testuser
+ http://example.net/mysite/user/3
+
+
+ http://activitystrea.ms/schema/1.0/person
+ http://example.net/mysite/user/3
+ Test User
+
+
+ 37.7749295 -122.4194155
+
+testuser
+Test User
+Just another test user.
+
+ San Francisco, CA
+
+
+ homepage
+ http://example.com/blog.html
+ true
+
+
+
+
+ http://example.net/mysite/notice/7
+ 2010-02-24T00:53:06+00:00
+ 2010-02-24T00:53:06+00:00
+
+ Hey man, is that Freedom Code?! #<span class="tag"><a href="http://example.net/mysite/tag/freedom" rel="tag">freedom</a></span> #<span class="tag"><a href="http://example.net/mysite/tag/hippy" rel="tag">hippy</a></span>
+ 37.8313160 -122.2852473
+
+
+
+EXAMPLE5;
+
+$_example6 = <<
+
+
+
+ WordPress.com News
+
+ http://en.blog.wordpress.com
+ The latest news on WordPress.com and the WordPress community.
+ Thu, 18 Mar 2010 23:25:35 +0000
+
+ http://wordpress.com/
+ en
+ hourly
+ 1
+
+
+ http://www.gravatar.com/blavatar/e6392390e3bcfadff3671c5a5653d95b?s=96&d=http://s2.wp.com/i/buttonw-com.png
+ WordPress.com News
+ http://en.blog.wordpress.com
+
+
+
+
+ -
+
Rub-a-Dub-Dub in the PubSubHubbub
+ http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/
+ http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/#comments
+ Wed, 03 Mar 2010 16:48:12 +0000
+ Joseph Scott
+
+
+
+
+
+
+ http://en.blog.wordpress.com/?p=3857
+ ]]>
+ From the tongue twisting name department we welcome PubSubHubbub, or as some people have shortened it to: PuSH. Like rssCloud , PuSH is a way for services that subscribe to updates from your blog to get updates even faster. In a nutshell, instead of having to periodically ask your blog if there are any updates they can now register to automatically receive updates each time you publish new content. In most cases these updates are sent out within a second or two of when you hit the publish button.
+ Today we’ve turned on PuSH support for the more than 10.5 million blogs on WordPress.com. There’s nothing to configure, it’s working right now behind the scenes to help others keep up to date with your posts.
+ For those using the WordPress.org software we are releasing a new PuSH plugin: PuSHPress . This plugin differs from the current PuSH related plugins by including a built-in hub.
+ ]]>
+ http://en.blog.wordpress.com/2010/03/03/rub-a-dub-dub-in-the-pubsubhubbub/feed/
+
+ 96
+
+
+ josephscott
+
+
+
+
+EXAMPLE6;
+
+$_example7 = <<
+
+
+ evanpro's posterous
+ http://evanpro.posterous.com
+ Most recent posts at evanpro's posterous
+ posterous.com
+
+
+
+ -
+
Sat, 20 Mar 2010 07:32:31 -0700
+ Checking out captain bones
+ http://evanpro.posterous.com/checking-out-captain-bones
+ http://evanpro.posterous.com/checking-out-captain-bones
+
+
+ Bones!
+
+
+
+ Permalink
+
+ | Leave a comment »
+
+
]]>
+
+
+ http://files.posterous.com/user_profile_pics/480326/2009-08-05-142447.jpg
+ http://posterous.com/people/3sDslhaepotz
+ Evan
+ Prodromou
+ evanpro
+ Evan Prodromou
+
+
+
+
+EXAMPLE7;
+
+$_example8 = <<
+
+
+ Activity Stream for: zcopley
+ http://cliqset.com/feed/atom?uid=zcopley
+
+ 0
+ http://activitystrea.ms/schema/1.0/post
+ 2010-03-22T01:35:53.000Z
+
+ flickr
+ http://flickr.com
+ http://cliqset-services.s3.amazonaws.com/flickr.png
+
+
+ http://activitystrea.ms/schema/1.0/photo
+ IMG_1368
+
+
+
+
+ http://activitystrea.ms/schema/1.0/photo
+ IMG_1365
+
+
+
+
+ http://activitystrea.ms/schema/1.0/photo
+ Classic
+
+
+ -Powered by pikchur.com/n0u
+
+
+ http://activitystrea.ms/schema/1.0/photo
+ IMG_1363
+
+
+
+
+ http://activitystrea.ms/schema/1.0/photo
+ IMG_1361
+
+
+
+ zcopley posted some photos on Flickr
+ zcopley posted 5 photos on Flickr
+
+ 2010-03-22T20:46:42.778Z
+ tag:cliqset.com,2010-03-22:/user/zcopley/SVgAZubGhtAnSAee
+
+
+ zcopley
+ http://cliqset.com/user/zcopley
+
+
+ http://activitystrea.ms/schema/1.0/person
+ zcopley
+
+ Zach
+ Copley
+
+
+
+
+
+
+
+EXAMPLE8;
+
+$_example9 = <<
+
+
+
+ Test
+ 2010-03-22T01:55:53.596Z
+ test53725745374
+ test
+
+ Buzz by Zach Copley from Flickr
+ IMG_1366
+ 2010-03-18T04:29:23.000Z
+ 2010-03-18T05:14:03.325Z
+ test53725745374entry
+
+
+ Zach Copley
+ https://mywebsite.net/profiles/zcopley
+
+ <div>IMG_1366</div>
+
+
+ IMG_1366
+
+
+
+
+ IMG_1365
+
+
+ http://activitystrea.ms/schema/1.0/post
+
+ http://activitystrea.ms/schema/1.0/photo
+ test53725745374entry
+ Buzz by Zach Copley from Flickr
+ <div>IMG_1366</div>
+
+
+
+
+ 0
+
+
+EXAMPLE9;
+
+// Sample PuSH entry from a group feed in 0.9.7
+// Old has been removed from entries in this version.
+// A bug in the order of input processing meant that we were incorrectly
+// reading the feed's instead of the entry's ,
+// causing the entry to get rejected as malformed (groups can't post on
+// their own; we want to see the actual author's info here).
+$_example10 = <<
+
+ StatusNet
+ http://lazarus.local/mublog/api/statusnet/groups/timeline/22.atom
+ grouptest316173 timeline
+ Updates from grouptest316173 on Blaguette!
+ http://lazarus.local/mublog/theme/default/default-avatar-profile.png
+ 2011-01-06T22:44:18+00:00
+
+ http://activitystrea.ms/schema/1.0/group
+ http://lazarus.local/mublog/group/22/id
+ grouptest316173
+
+
+
+
+ grouptest316173
+ grouptest316173
+
+
+ http://activitystrea.ms/schema/1.0/group
+ http://lazarus.local/mublog/group/22/id
+ grouptest316173
+
+
+
+
+ grouptest316173
+ grouptest316173
+
+
+
+
+
+
+
+
+
+ http://activitystrea.ms/schema/1.0/note
+ http://lazarus.local/mublog/notice/1243
+ Group post from local to !grouptest316173, should go out over push.
+ Group post from local to !<span class="vcard"><a href="http://lazarus.local/mublog/group/22/id" class="url"><span class="fn nickname">grouptest316173</span></a></span>, should go out over push.
+
+ http://activitystrea.ms/schema/1.0/post
+ 2011-01-06T22:44:18+00:00
+ 2011-01-06T22:44:18+00:00
+
+ http://activitystrea.ms/schema/1.0/person
+ http://lazarus.local/mublog/user/557
+ Pubtest316173 Smith
+
+
+
+
+ pubtest316173
+ Pubtest316173 Smith
+ Stub account for OStatus tests.
+
+ homepage
+ http://example.org/pubtest316173
+ true
+
+
+
+
+
+
+ http://lazarus.local/mublog/api/statuses/user_timeline/557.atom
+ Pubtest316173 Smith
+
+
+
+ http://lazarus.local/mublog/theme/default/default-avatar-profile.png
+ 2011-01-06T22:44:18+00:00
+
+
+
+
+
+
+EXAMPLE10;
+
+$_example11 = <<
+
+ StatusNet
+ http://freelish.us/api/statuses/user_timeline/1.atom
+ demon timeline
+ Updates from demon on freelish.us!
+ http://avatar.status.net/f/freelishus/1-96-20110331163048.jpeg
+ 2011-05-30T09:36:03-04:00
+
+ http://activitystrea.ms/schema/1.0/person
+ http://freelishus.status.net/user/1
+ demon
+
+
+
+
+
+ 45.50884 -73.58781
+ demon
+ Evan Prodromou
+ Montreal hacker and entrepreneur.
+
+ Montreal, Quebec
+
+
+
+ homepage
+ http://evan.status.net/
+ true
+
+
+
+
+
+ http://activitystrea.ms/schema/1.0/person
+ http://freelishus.status.net/user/1
+ Evan Prodromou
+
+
+
+
+
+ 45.50884 -73.58781
+ demon
+ Evan Prodromou
+ Montreal hacker and entrepreneur.
+
+ Montreal, Quebec
+
+
+
+ homepage
+ http://evan.status.net/
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+ http://activitystrea.ms/schema/1.0/bookmark
+ http://freelish.us/bookmark/9e930c3e-7ed9-47de-aba5-df6c60cec542
+ Why you should build an open-source startup | Teambox Blog
+
+
+ http://activitystrea.ms/schema/1.0/post
+ 2011-05-26T20:36:25+00:00
+ 2011-05-26T20:36:25+00:00
+
+
+
+
+
+
+
+
+
+EXAMPLE11;
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/Core/CommandInterperterTest.php b/tests/Core/CommandInterperterTest.php
new file mode 100644
index 0000000000..d8f6149a7c
--- /dev/null
+++ b/tests/Core/CommandInterperterTest.php
@@ -0,0 +1,194 @@
+.
+
+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 CommandInterpreter;
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class CommandInterpreterTest extends TestCase
+{
+
+ /**
+ * @dataProvider commandInterpreterCases
+ * @param $input
+ * @param $expectedType
+ * @param string $comment
+ */
+ public function testCommandInterpreter($input, $expectedType, $comment = '')
+ {
+ $inter = new CommandInterpreter();
+
+ $cmd = $inter->handle_command(null, $input);
+
+ $type = $cmd ? get_class($cmd) : null;
+ $this->assertEquals(strtolower($expectedType), strtolower($type), $comment);
+ }
+
+ static public function commandInterpreterCases()
+ {
+ $sets = array(
+ array('help', 'HelpCommand'),
+ array('help me bro', null, 'help does not accept multiple params'),
+ array('HeLP', 'HelpCommand', 'case check'),
+ array('HeLP Me BRO!', null, 'case & non-params check'),
+
+ array('login', 'LoginCommand'),
+ array('login to savings!', null, 'login does not accept params'),
+
+ array('lose', null, 'lose must have at least 1 parameter'),
+ array('lose foobar', 'LoseCommand', 'lose requires 1 parameter'),
+ array('lose foobar', 'LoseCommand', 'check for space norm'),
+ array('lose more weight', null, 'lose does not accept multiple params'),
+
+ array('subscribers', 'SubscribersCommand'),
+ array('subscribers foo', null, 'subscribers does not take params'),
+
+ array('subscriptions', 'SubscriptionsCommand'),
+ array('subscriptions foo', null, 'subscriptions does not take params'),
+
+ array('groups', 'GroupsCommand'),
+ array('groups foo', null, 'groups does not take params'),
+
+ array('off', 'OffCommand', 'off accepts 0 or 1 params'),
+ array('off foo', 'OffCommand', 'off accepts 0 or 1 params'),
+ array('off foo bar', null, 'off accepts 0 or 1 params'),
+
+ array('stop', 'OffCommand', 'stop accepts 0 params'),
+ array('stop foo', null, 'stop accepts 0 params'),
+
+ array('quit', 'OffCommand', 'quit accepts 0 params'),
+ array('quit foo', null, 'quit accepts 0 params'),
+
+ array('on', 'OnCommand', 'on accepts 0 or 1 params'),
+ array('on foo', 'OnCommand', 'on accepts 0 or 1 params'),
+ array('on foo bar', null, 'on accepts 0 or 1 params'),
+
+ array('join', null),
+ array('join foo', 'JoinCommand'),
+ array('join foo bar', null),
+
+ array('drop', null),
+ array('drop foo', 'DropCommand'),
+ array('drop foo bar', null),
+
+ array('follow', null),
+ array('follow foo', 'SubCommand'),
+ array('follow foo bar', null),
+
+ array('sub', null),
+ array('sub foo', 'SubCommand'),
+ array('sub foo bar', null),
+
+ array('leave', null),
+ array('leave foo', 'UnsubCommand'),
+ array('leave foo bar', null),
+
+ array('unsub', null),
+ array('unsub foo', 'UnsubCommand'),
+ array('unsub foo bar', null),
+
+ array('leave', null),
+ array('leave foo', 'UnsubCommand'),
+ array('leave foo bar', null),
+
+ array('d', null),
+ array('d foo', null),
+ array('d foo bar', 'MessageCommand'),
+
+ array('dm', null),
+ array('dm foo', null),
+ array('dm foo bar', 'MessageCommand'),
+
+ array('r', null),
+ array('r foo', null),
+ array('r foo bar', 'ReplyCommand'),
+
+ array('reply', null),
+ array('reply foo', null),
+ array('reply foo bar', 'ReplyCommand'),
+
+ array('repeat', null),
+ array('repeat foo', 'RepeatCommand'),
+ array('repeat foo bar', null),
+
+ array('rp', null),
+ array('rp foo', 'RepeatCommand'),
+ array('rp foo bar', null),
+
+ array('rt', null),
+ array('rt foo', 'RepeatCommand'),
+ array('rt foo bar', null),
+
+ array('rd', null),
+ array('rd foo', 'RepeatCommand'),
+ array('rd foo bar', null),
+
+ array('whois', null),
+ array('whois foo', 'WhoisCommand'),
+ array('whois foo bar', null),
+
+ /* array('fav', null),
+ array('fav foo', 'FavCommand'),
+ array('fav foo bar', null),*/
+
+ array('nudge', null),
+ array('nudge foo', 'NudgeCommand'),
+ array('nudge foo bar', null),
+
+ array('stats', 'StatsCommand'),
+ array('stats foo', null),
+
+ array('invite', null),
+ array('invite foo', 'InviteCommand'),
+ array('invite foo bar', null),
+
+ array('track', null),
+ array('track foo', 'SearchSubTrackCommand'),
+ array('track off', 'SearchSubTrackOffCommand'),
+ array('track foo bar', null),
+ array('track off foo', null),
+
+ array('untrack', null),
+ array('untrack foo', 'SearchSubUntrackCommand'),
+ array('untrack all', 'SearchSubTrackOffCommand'),
+ array('untrack foo bar', null),
+ array('untrack all foo', null),
+
+ array('tracking', 'SearchSubTrackingCommand'),
+ array('tracking foo', null),
+
+ array('tracks', 'SearchSubTrackingCommand'),
+ array('tracks foo', null),
+
+ );
+ return $sets;
+ }
+
+}
+
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/Core/UserFeedParseTest.php b/tests/Core/UserFeedParseTest.php
new file mode 100644
index 0000000000..f2685469d9
--- /dev/null
+++ b/tests/Core/UserFeedParseTest.php
@@ -0,0 +1,155 @@
+.
+
+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 Activity;
+use ActivityObject;
+use DOMDocument;
+use PHPUnit\Framework\TestCase;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class UserFeedParseTests extends TestCase
+{
+ public function testFeed1()
+ {
+ global $_testfeed1;
+ $dom = new DOMDocument();
+ $dom->loadXML($_testfeed1);
+ $this->assertFalse(empty($dom));
+
+ $entries = $dom->getElementsByTagName('entry');
+
+ $entry1 = $entries->item(0);
+ $this->assertFalse(empty($entry1));
+
+ $feedEl = $dom->getElementsByTagName('feed')->item(0);
+ $this->assertFalse(empty($feedEl));
+
+ // Test actor (from activity:subject)
+
+ $act1 = new Activity($entry1, $feedEl);
+ $this->assertFalse(empty($act1));
+ $this->assertFalse(empty($act1->actor));
+ $this->assertEquals($act1->actor->type, ActivityObject::PERSON);
+ $this->assertEquals($act1->actor->title, 'Zach Copley');
+ $this->assertEquals($act1->actor->id, 'http://localhost/statusnet/user/1');
+ $this->assertEquals($act1->actor->link, 'http://localhost/statusnet/zach');
+
+ $avatars = $act1->actor->avatarLinks;
+
+ $this->assertEquals(
+ $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'
+ );
+
+ $this->assertEquals(
+ $avatars[2]->url,
+ 'http://localhost/statusnet/theme/default/default-avatar-mini.png'
+ );
+
+ $this->assertEquals($act1->actor->displayName, 'Zach Copley');
+
+ $poco = $act1->actor->poco;
+ $this->assertEquals($poco->preferredUsername, 'zach');
+ $this->assertEquals($poco->address->formatted, 'El Cerrito, CA');
+ $this->assertEquals($poco->urls[0]->type, 'homepage');
+ $this->assertEquals($poco->urls[0]->value, 'http://zach.copley.name');
+ $this->assertEquals($poco->urls[0]->primary, true);
+ $this->assertEquals($poco->note, 'Zach Hack Attack');
+
+ // test the post
+
+ //var_export($act1);
+ $this->assertEquals($act1->objects[0]->type, 'http://activitystrea.ms/schema/1.0/note');
+ $this->assertEquals($act1->objects[0]->title, 'And now for something completely insane...');
+
+ $this->assertEquals($act1->objects[0]->content, 'And now for something completely insane...');
+ $this->assertEquals($act1->objects[0]->id, 'http://localhost/statusnet/notice/3');
+
+ }
+
+}
+
+$_testfeed1 = <<
+
+ http://localhost/statusnet/api/statuses/user_timeline/1.atom
+ zach timeline
+ Updates from zach on Zach Dev!
+ http://localhost/statusnet/theme/default/default-avatar-profile.png
+ 2010-03-04T01:41:14+00:00
+
+ zach
+ http://localhost/statusnet/user/1
+
+
+
+
+
+
+
+
+
+ http://activitystrea.ms/schema/1.0/person
+ http://localhost/statusnet/user/1
+ Zach Copley
+
+
+
+
+
+zach
+Zach Copley
+Zach Hack Attack
+
+ El Cerrito, CA
+
+
+ homepage
+ http://zach.copley.name
+ true
+
+
+
+
+ And now for something completely insane...
+
+ http://localhost/statusnet/notice/3
+ 2010-03-04T01:41:07+00:00
+ 2010-03-04T01:41:07+00:00
+
+ And now for something completely insane...
+
+
+
+TESTFEED1;
diff --git a/tests/Core/UserRightsTest.php b/tests/Core/UserRightsTest.php
new file mode 100644
index 0000000000..42af9ba683
--- /dev/null
+++ b/tests/Core/UserRightsTest.php
@@ -0,0 +1,94 @@
+.
+
+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 Exception;
+use PHPUnit\Framework\TestCase;
+use User;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class UserRightsTest extends TestCase
+{
+ protected $user = null;
+
+ function setUp()
+ {
+ $user = User::getKV('nickname', 'userrightstestuser');
+ if ($user) {
+ // Leftover from a broken test run?
+ $profile = $user->getProfile();
+ $user->delete();
+ $profile->delete();
+ }
+ $this->user = User::register(array('nickname' => 'userrightstestuser'));
+ if (!$this->user) {
+ throw new Exception("Couldn't register userrightstestuser");
+ }
+ }
+
+ function tearDown()
+ {
+ if ($this->user) {
+ $profile = $this->user->getProfile();
+ $this->user->delete();
+ $profile->delete();
+ }
+ }
+
+ function testInvalidRole()
+ {
+ $this->assertFalse($this->user->hasRole('invalidrole'));
+ }
+
+ function standardRoles()
+ {
+ return array(array('admin'),
+ array('moderator'));
+ }
+
+ /**
+ * @dataProvider standardRoles
+ * @param $role
+ */
+
+ function testUngrantedRole($role)
+ {
+ $this->assertFalse($this->user->hasRole($role));
+ }
+
+ /**
+ * @dataProvider standardRoles
+ * @param $role
+ */
+
+ function testGrantedRole($role)
+ {
+ $this->user->grantRole($role);
+ $this->assertTrue($this->user->hasRole($role));
+ }
+}
diff --git a/tests/Core/XmppValidateTest.php b/tests/Core/XmppValidateTest.php
new file mode 100644
index 0000000000..f751eb092f
--- /dev/null
+++ b/tests/Core/XmppValidateTest.php
@@ -0,0 +1,199 @@
+.
+
+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 GNUsocial;
+use PHPUnit\Framework\TestCase;
+use XmppPlugin;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+require_once INSTALLDIR . '/plugins/Xmpp/XmppPlugin.php';
+
+final class XmppValidateTest extends TestCase
+{
+ 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));
+ $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();
+ $this->assertEquals($expected, $xmpp->normalize($jid));
+ }
+
+ /**
+ * @dataProvider domainCheckCases()
+ * @param $domain
+ * @param $expected
+ * @param $note
+ */
+ public function testDomainCheck($domain, $expected, $note)
+ {
+ $xmpp = new TestXmppPlugin();
+ $this->assertEquals($expected, $xmpp->checkDomain($domain), $note);
+ }
+
+ static public function validationCases()
+ {
+ $long1023 = "long1023" . str_repeat('x', 1023 - 8);
+ $long1024 = "long1024" . str_repeat('x', 1024 - 8);
+ return array(
+ // Our own test cases for standard things & those mentioned in bug reports
+ // (jid, valid_full, valid_base)
+ array('user@example.com', true, true),
+ array('user@example.com/resource', true, false),
+ array('user with spaces@example.com', false, false), // not kosher
+
+ array('user.@example.com', true, true), // "common in intranets"
+ 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),
+ array("$long1023@$long1023/$long1024", false, false),
+
+ // Borrowed from test_jabber_jutil.c in libpurple
+ array("gmail.com", true, true),
+ array("gmail.com/Test", true, false),
+ array("gmail.com/Test@", true, false),
+ array("gmail.com/@", true, false),
+ array("gmail.com/Test@alkjaweflkj", true, false),
+ array("mark.doliner@gmail.com", true, true),
+ array("mark.doliner@gmail.com/Test12345", true, false),
+ array("mark.doliner@gmail.com/Test@12345", true, false),
+ array("mark.doliner@gmail.com/Te/st@12@//345", true, false),
+ array("ããã©@conference.jabber.org", true, true),
+ array("ã¾ããã¼ã@conference.jabber.org", true, true),
+ array("mark.doliner@gmail.com/ã¾ããã¼ã", true, false),
+ array("mark.doliner@gmail/stuff.org", true, false),
+ array("stuart@nödåtXäYZ.se", true, true),
+ array("stuart@nödÃ¥tXäYZ.se/ã¾ããã¼ã", true, false),
+ array("mark.doliner@ããã©.org", true, true),
+ array("nick@ã¾ã¤.ãããã¿.net", true, true),
+ array("paul@10.0.42.230/s", true, false),
+ array("paul@[::1]", true, true), /* IPv6 */
+ array("paul@[2001:470:1f05:d58::2]", true, true),
+ array("paul@[2001:470:1f05:d58::2]/foo", true, false),
+ array("pa=ul@10.0.42.230", true, true),
+ array("pa,ul@10.0.42.230", true, true),
+
+ array("@gmail.com", false, false),
+ array("@@gmail.com", false, false),
+ array("mark.doliner@@gmail.com/Test12345", false, false),
+ array("mark@doliner@gmail.com/Test12345", false, false),
+ array("@gmail.com/Test@12345", false, false),
+ array("/Test@12345", false, false),
+ array("mark.doliner@", false, false),
+ array("mark.doliner/", false, false),
+ array("mark.doliner@gmail_stuff.org", false, false),
+ array("mark.doliner@gmail[stuff.org", false, false),
+ array("mark.doliner@gmail\\stuff.org", false, false),
+ array("paul@[::1]124", false, false),
+ array("paul@2[::1]124/as", false, false),
+ array("paul@ã¾ã¤.ãããã¿/\x01", false, false),
+
+ /*
+ * RFC 3454 Section 6 reads, in part,
+ * "If a string contains any RandALCat character, the
+ * string MUST NOT contain any LCat character."
+ * The character is U+066D (ARABIC FIVE POINTED STAR).
+ */
+ // Leaving this one commented out for the moment
+ // as it shouldn't hurt anything for our purposes.
+ //array("foo@example.com/ÙsimplexeÙ", false, false)
+ );
+ }
+
+ static public function normalizationCases()
+ {
+ return array(
+ // Borrowed from test_jabber_jutil.c in libpurple
+ array('PaUL@DaRkRain42.org', 'paul@darkrain42.org'),
+ array('PaUL@DaRkRain42.org/', 'paul@darkrain42.org'),
+ array('PaUL@DaRkRain42.org/resource', 'paul@darkrain42.org'),
+
+ // Also adapted from libpurple tests...
+ array('Ф@darkrain42.org', 'Ñ@darkrain42.org'),
+ array('paul@Ó¨arkrain.org', 'paul@Ó©arkrain.org'),
+ );
+ }
+
+ static public function domainCheckCases()
+ {
+ return array(
+ array('gmail.com', true, 'known SRV record'),
+ array('jabber.org', true, 'known SRV record'),
+ array('status.net', true, 'known SRV record'),
+ array('status.leuksman.com', true, 'known no SRV record but valid domain'),
+ );
+ }
+
+
+}
+
+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/Media/MediaFileTest.php b/tests/Media/MediaFileTest.php
new file mode 100644
index 0000000000..cd28941896
--- /dev/null
+++ b/tests/Media/MediaFileTest.php
@@ -0,0 +1,122 @@
+.
+
+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 ClientException;
+use Exception;
+use MediaFile;
+use PHPUnit\Framework\TestCase;
+use ServerException;
+
+require_once INSTALLDIR . '/lib/common.php';
+
+final class MediaFileTest extends TestCase
+{
+
+ public function setup()
+ {
+ $this->old_attachments_supported = common_config('attachments', 'supported');
+ $GLOBALS['config']['attachments']['supported'] = true;
+ }
+
+ public function tearDown()
+ {
+ $GLOBALS['config']['attachments']['supported'] = $this->old_attachments_supported;
+ }
+
+ /**
+ * @dataProvider fileTypeCases
+ * @param $filename
+ * @param $expectedType
+ * @throws ClientException
+ * @throws ServerException
+ */
+ public function testMimeType($filename, $expectedType)
+ {
+ if (!file_exists($filename)) {
+ throw new Exception("Test file $filename missing");
+ }
+
+ $type = MediaFile::getUploadedMimeType($filename, basename($filename));
+ $this->assertEquals($expectedType, $type);
+ }
+
+ /**
+ * @dataProvider fileTypeCases
+ * @param $filename
+ * @param $expectedType
+ * @throws ClientException
+ * @throws ServerException
+ */
+ public function testUploadedMimeType($filename, $expectedType)
+ {
+ if (!file_exists($filename)) {
+ throw new Exception("WTF? $filename test file missing");
+ }
+ $tmp = tmpfile();
+ fwrite($tmp, file_get_contents($filename));
+
+ $tmp_metadata = stream_get_meta_data($tmp);
+ $type = MediaFile::getUploadedMimeType($tmp_metadata['uri'], basename($filename));
+ $this->assertEquals($expectedType, $type);
+ }
+
+ static public function fileTypeCases()
+ {
+ $base = dirname(__FILE__);
+ $dir = "$base/sample-uploads";
+ $files = array(
+ "image.png" => "image/png",
+ "image.gif" => "image/gif",
+ "image.jpg" => "image/jpeg",
+ "image.jpeg" => "image/jpeg",
+ "office.pdf" => "application/pdf",
+ "wordproc.odt" => "application/vnd.oasis.opendocument.text",
+ "wordproc.ott" => "application/vnd.oasis.opendocument.text-template",
+ "wordproc.doc" => "application/msword",
+ "wordproc.docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+ "wordproc.rtf" => "text/rtf",
+ "spreadsheet.ods" => "application/vnd.oasis.opendocument.spreadsheet",
+ "spreadsheet.ots" => "application/vnd.oasis.opendocument.spreadsheet-template",
+ "spreadsheet.xls" => "application/vnd.ms-excel",
+ "spreadsheet.xlt" => "application/vnd.ms-excel",
+ "spreadsheet.xlsx" =>"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ "presentation.odp" => "application/vnd.oasis.opendocument.presentation",
+ "presentation.otp" => "application/vnd.oasis.opendocument.presentation-template",
+ "presentation.ppt" => "application/vnd.ms-powerpoint",
+ "presentation.pptx" => 'application/zip', //"application/vnd.openxmlformats-officedocument.presentationml.presentation",
+ );
+
+ $dataset = array();
+ foreach ($files as $file => $type) {
+ $dataset[] = array("$dir/$file", $type);
+ }
+ return $dataset;
+ }
+
+}
+
diff --git a/tests/Media/sample-uploads/image.gif b/tests/Media/sample-uploads/image.gif
new file mode 100644
index 0000000000..b636f4b8df
Binary files /dev/null and b/tests/Media/sample-uploads/image.gif differ
diff --git a/tests/Media/sample-uploads/image.jpeg b/tests/Media/sample-uploads/image.jpeg
new file mode 100644
index 0000000000..21fcb5aef4
Binary files /dev/null and b/tests/Media/sample-uploads/image.jpeg differ
diff --git a/tests/Media/sample-uploads/image.jpg b/tests/Media/sample-uploads/image.jpg
new file mode 100644
index 0000000000..21fcb5aef4
Binary files /dev/null and b/tests/Media/sample-uploads/image.jpg differ
diff --git a/tests/Media/sample-uploads/image.png b/tests/Media/sample-uploads/image.png
new file mode 100644
index 0000000000..60cbcfd17f
Binary files /dev/null and b/tests/Media/sample-uploads/image.png differ
diff --git a/tests/Media/sample-uploads/office.pdf b/tests/Media/sample-uploads/office.pdf
new file mode 100644
index 0000000000..670bc2343e
Binary files /dev/null and b/tests/Media/sample-uploads/office.pdf differ
diff --git a/tests/Media/sample-uploads/presentation.odp b/tests/Media/sample-uploads/presentation.odp
new file mode 100644
index 0000000000..8dd3a428bc
Binary files /dev/null and b/tests/Media/sample-uploads/presentation.odp differ
diff --git a/tests/Media/sample-uploads/presentation.otp b/tests/Media/sample-uploads/presentation.otp
new file mode 100644
index 0000000000..1927ee79dd
Binary files /dev/null and b/tests/Media/sample-uploads/presentation.otp differ
diff --git a/tests/Media/sample-uploads/presentation.pot b/tests/Media/sample-uploads/presentation.pot
new file mode 100644
index 0000000000..f5124ffa2b
Binary files /dev/null and b/tests/Media/sample-uploads/presentation.pot differ
diff --git a/tests/Media/sample-uploads/presentation.potm b/tests/Media/sample-uploads/presentation.potm
new file mode 100644
index 0000000000..ade1bcb10f
Binary files /dev/null and b/tests/Media/sample-uploads/presentation.potm differ
diff --git a/tests/Media/sample-uploads/presentation.ppt b/tests/Media/sample-uploads/presentation.ppt
new file mode 100644
index 0000000000..f5124ffa2b
Binary files /dev/null and b/tests/Media/sample-uploads/presentation.ppt differ
diff --git a/tests/Media/sample-uploads/presentation.pptx b/tests/Media/sample-uploads/presentation.pptx
new file mode 100644
index 0000000000..21ea61a159
Binary files /dev/null and b/tests/Media/sample-uploads/presentation.pptx differ
diff --git a/tests/Media/sample-uploads/spreadsheet.ods b/tests/Media/sample-uploads/spreadsheet.ods
new file mode 100644
index 0000000000..7b43e75075
Binary files /dev/null and b/tests/Media/sample-uploads/spreadsheet.ods differ
diff --git a/tests/Media/sample-uploads/spreadsheet.ots b/tests/Media/sample-uploads/spreadsheet.ots
new file mode 100644
index 0000000000..5f830e6def
Binary files /dev/null and b/tests/Media/sample-uploads/spreadsheet.ots differ
diff --git a/tests/Media/sample-uploads/spreadsheet.xls b/tests/Media/sample-uploads/spreadsheet.xls
new file mode 100644
index 0000000000..2d470e6871
Binary files /dev/null and b/tests/Media/sample-uploads/spreadsheet.xls differ
diff --git a/tests/Media/sample-uploads/spreadsheet.xlsx b/tests/Media/sample-uploads/spreadsheet.xlsx
new file mode 100644
index 0000000000..b97a551f86
Binary files /dev/null and b/tests/Media/sample-uploads/spreadsheet.xlsx differ
diff --git a/tests/Media/sample-uploads/spreadsheet.xlt b/tests/Media/sample-uploads/spreadsheet.xlt
new file mode 100644
index 0000000000..980423b20f
Binary files /dev/null and b/tests/Media/sample-uploads/spreadsheet.xlt differ
diff --git a/tests/Media/sample-uploads/wordproc.doc b/tests/Media/sample-uploads/wordproc.doc
new file mode 100644
index 0000000000..81c5e34c6c
Binary files /dev/null and b/tests/Media/sample-uploads/wordproc.doc differ
diff --git a/tests/Media/sample-uploads/wordproc.docx b/tests/Media/sample-uploads/wordproc.docx
new file mode 100644
index 0000000000..04ea3c3ec1
Binary files /dev/null and b/tests/Media/sample-uploads/wordproc.docx differ
diff --git a/tests/Media/sample-uploads/wordproc.odt b/tests/Media/sample-uploads/wordproc.odt
new file mode 100644
index 0000000000..fa6fe5e9ff
Binary files /dev/null and b/tests/Media/sample-uploads/wordproc.odt differ
diff --git a/tests/Media/sample-uploads/wordproc.ott b/tests/Media/sample-uploads/wordproc.ott
new file mode 100644
index 0000000000..99ca8c0684
Binary files /dev/null and b/tests/Media/sample-uploads/wordproc.ott differ
diff --git a/tests/Media/sample-uploads/wordproc.rtf b/tests/Media/sample-uploads/wordproc.rtf
new file mode 100644
index 0000000000..aad2c4605e
--- /dev/null
+++ b/tests/Media/sample-uploads/wordproc.rtf
@@ -0,0 +1,16 @@
+{\rtf1\ansi\deff0\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset128 Times New Roman;}{\f1\froman\fprq2\fcharset128 Times New Roman;}{\f2\fswiss\fprq2\fcharset128 Arial;}{\f3\fnil\fprq2\fcharset128 DejaVu Sans;}}
+{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
+{\stylesheet{\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\snext1 Normal;}
+{\s2\sb240\sa120\keepn\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\afs28\lang1081\ltrch\dbch\langfe2052\hich\f2\fs28\lang1033\loch\f2\fs28\lang1033\sbasedon1\snext3 Heading;}
+{\s3\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon1\snext3 Body Text;}
+{\s4\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon3\snext4 List;}
+{\s5\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ai\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\i\loch\f0\fs24\lang1033\i\sbasedon1\snext5 caption;}
+{\s6\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon1\snext6 Index;}
+}
+{\info{\author Brion }{\creatim\yr2010\mo5\dy10\hr15\min2}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment StarWriter}{\vern3200}}\deftab709
+{\*\pgdsctbl
+{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Standard;}}
+\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+\pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033
+\par }
\ No newline at end of file
diff --git a/tests/MediaFileTest.php b/tests/MediaFileTest.php
deleted file mode 100644
index 1e4a3c9dbb..0000000000
--- a/tests/MediaFileTest.php
+++ /dev/null
@@ -1,93 +0,0 @@
-old_attachments_supported = common_config('attachments', 'supported');
- $GLOBALS['config']['attachments']['supported'] = true;
- }
-
- public function tearDown()
- {
- $GLOBALS['config']['attachments']['supported'] = $this->old_attachments_supported;
- }
-
- /**
- * @dataProvider fileTypeCases
- *
- */
- public function testMimeType($filename, $expectedType)
- {
- if (!file_exists($filename)) {
- throw new Exception("Test file $filename missing");
- }
-
- $type = MediaFile::getUploadedMimeType($filename, basename($filename));
- $this->assertEquals($expectedType, $type);
- }
-
- /**
- * @dataProvider fileTypeCases
- *
- */
- public function testUploadedMimeType($filename, $expectedType)
- {
- if (!file_exists($filename)) {
- throw new Exception("WTF? $filename test file missing");
- }
- $tmp = tmpfile();
- fwrite($tmp, file_get_contents($filename));
-
- $tmp_metadata = stream_get_meta_data($tmp);
- $type = MediaFile::getUploadedMimeType($tmp_metadata['uri'], basename($filename));
- $this->assertEquals($expectedType, $type);
- }
-
- static public function fileTypeCases()
- {
- $base = dirname(__FILE__);
- $dir = "$base/sample-uploads";
- $files = array(
- "image.png" => "image/png",
- "image.gif" => "image/gif",
- "image.jpg" => "image/jpeg",
- "image.jpeg" => "image/jpeg",
- "office.pdf" => "application/pdf",
- "wordproc.odt" => "application/vnd.oasis.opendocument.text",
- "wordproc.ott" => "application/vnd.oasis.opendocument.text-template",
- "wordproc.doc" => "application/msword",
- "wordproc.docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
- "wordproc.rtf" => "text/rtf",
- "spreadsheet.ods" => "application/vnd.oasis.opendocument.spreadsheet",
- "spreadsheet.ots" => "application/vnd.oasis.opendocument.spreadsheet-template",
- "spreadsheet.xls" => "application/vnd.ms-excel",
- "spreadsheet.xlt" => "application/vnd.ms-excel",
- "spreadsheet.xlsx" =>"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
- "presentation.odp" => "application/vnd.oasis.opendocument.presentation",
- "presentation.otp" => "application/vnd.oasis.opendocument.presentation-template",
- "presentation.ppt" => "application/vnd.ms-powerpoint",
- "presentation.pptx" => 'application/zip', //"application/vnd.openxmlformats-officedocument.presentationml.presentation",
- );
-
- $dataset = array();
- foreach ($files as $file => $type) {
- $dataset[] = array("$dir/$file", $type);
- }
- return $dataset;
- }
-
-}
-
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");
- }
-}
-
diff --git a/tests/UserFeedParseTest.php b/tests/UserFeedParseTest.php
deleted file mode 100644
index b68783bb03..0000000000
--- a/tests/UserFeedParseTest.php
+++ /dev/null
@@ -1,132 +0,0 @@
-assertFalse(empty($dom));
-
- $entries = $dom->getElementsByTagName('entry');
-
- $entry1 = $entries->item(0);
- $this->assertFalse(empty($entry1));
-
- $feedEl = $dom->getElementsByTagName('feed')->item(0);
- $this->assertFalse(empty($feedEl));
-
- // Test actor (from activity:subject)
-
- $act1 = new Activity($entry1, $feedEl);
- $this->assertFalse(empty($act1));
- $this->assertFalse(empty($act1->actor));
- $this->assertEquals($act1->actor->type, ActivityObject::PERSON);
- $this->assertEquals($act1->actor->title, 'Zach Copley');
- $this->assertEquals($act1->actor->id, 'http://localhost/statusnet/user/1');
- $this->assertEquals($act1->actor->link, 'http://localhost/statusnet/zach');
-
- $avatars = $act1->actor->avatarLinks;
-
- $this->assertEquals(
- $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'
- );
-
- $this->assertEquals(
- $avatars[2]->url,
- 'http://localhost/statusnet/theme/default/default-avatar-mini.png'
- );
-
- $this->assertEquals($act1->actor->displayName, 'Zach Copley');
-
- $poco = $act1->actor->poco;
- $this->assertEquals($poco->preferredUsername, 'zach');
- $this->assertEquals($poco->address->formatted, 'El Cerrito, CA');
- $this->assertEquals($poco->urls[0]->type, 'homepage');
- $this->assertEquals($poco->urls[0]->value, 'http://zach.copley.name');
- $this->assertEquals($poco->urls[0]->primary, true);
- $this->assertEquals($poco->note, 'Zach Hack Attack');
-
- // test the post
-
- //var_export($act1);
- $this->assertEquals($act1->objects[0]->type, 'http://activitystrea.ms/schema/1.0/note');
- $this->assertEquals($act1->objects[0]->title, 'And now for something completely insane...');
-
- $this->assertEquals($act1->objects[0]->content, 'And now for something completely insane...');
- $this->assertEquals($act1->objects[0]->id, 'http://localhost/statusnet/notice/3');
-
- }
-
-}
-
-$_testfeed1 = <<
-
- http://localhost/statusnet/api/statuses/user_timeline/1.atom
- zach timeline
- Updates from zach on Zach Dev!
- http://localhost/statusnet/theme/default/default-avatar-profile.png
- 2010-03-04T01:41:14+00:00
-
- zach
- http://localhost/statusnet/user/1
-
-
-
-
-
-
-
-
-
- http://activitystrea.ms/schema/1.0/person
- http://localhost/statusnet/user/1
- Zach Copley
-
-
-
-
-
-zach
-Zach Copley
-Zach Hack Attack
-
- El Cerrito, CA
-
-
- homepage
- http://zach.copley.name
- true
-
-
-
-
- And now for something completely insane...
-
- http://localhost/statusnet/notice/3
- 2010-03-04T01:41:07+00:00
- 2010-03-04T01:41:07+00:00
-
- And now for something completely insane...
-
-
-
-TESTFEED1;
diff --git a/tests/UserRightsTest.php b/tests/UserRightsTest.php
deleted file mode 100644
index bd9124a91d..0000000000
--- a/tests/UserRightsTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
-getProfile();
- $user->delete();
- $profile->delete();
- }
- $this->user = User::register(array('nickname' => 'userrightstestuser'));
- if (!$this->user) {
- throw new Exception("Couldn't register userrightstestuser");
- }
- }
-
- function tearDown()
- {
- if ($this->user) {
- $profile = $this->user->getProfile();
- $this->user->delete();
- $profile->delete();
- }
- }
-
- function testInvalidRole()
- {
- $this->assertFalse($this->user->hasRole('invalidrole'));
- }
-
- function standardRoles()
- {
- return array(array('admin'),
- array('moderator'));
- }
-
- /**
- * @dataProvider standardRoles
- *
- */
-
- function testUngrantedRole($role)
- {
- $this->assertFalse($this->user->hasRole($role));
- }
-
- /**
- * @dataProvider standardRoles
- *
- */
-
- function testGrantedRole($role)
- {
- $this->user->grantRole($role);
- $this->assertTrue($this->user->hasRole($role));
- }
-}
diff --git a/tests/XmppValidateTest.php b/tests/XmppValidateTest.php
deleted file mode 100644
index f3377390aa..0000000000
--- a/tests/XmppValidateTest.php
+++ /dev/null
@@ -1,171 +0,0 @@
-markTestSkipped('XmppPlugin is not enabled.');
- }
- }
- /**
- * @dataProvider validationCases
- *
- */
- public function testValidate($jid, $validFull, $validBase)
- {
- $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
- *
- */
- public function testNormalize($jid, $expected)
- {
- $xmpp = new XmppPlugin();
- $this->assertEquals($expected, $xmpp->normalize($jid));
- }
-
- /**
- * @dataProvider domainCheckCases()
- */
- public function testDomainCheck($domain, $expected, $note)
- {
- $xmpp = new TestXmppPlugin();
- $this->assertEquals($expected, $xmpp->checkDomain($domain), $note);
- }
-
- static public function validationCases()
- {
- $long1023 = "long1023" . str_repeat('x', 1023 - 8);
- $long1024 = "long1024" . str_repeat('x', 1024 - 8);
- return array(
- // Our own test cases for standard things & those mentioned in bug reports
- // (jid, valid_full, valid_base)
- array('user@example.com', true, true),
- array('user@example.com/resource', true, false),
- array('user with spaces@example.com', false, false), // not kosher
-
- array('user.@example.com', true, true), // "common in intranets"
- 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),
- array("$long1023@$long1023/$long1024", false, false),
-
- // Borrowed from test_jabber_jutil.c in libpurple
- array("gmail.com", true, true),
- array("gmail.com/Test", true, false),
- array("gmail.com/Test@", true, false),
- array("gmail.com/@", true, false),
- array("gmail.com/Test@alkjaweflkj", true, false),
- array("mark.doliner@gmail.com", true, true),
- array("mark.doliner@gmail.com/Test12345", true, false),
- array("mark.doliner@gmail.com/Test@12345", true, false),
- array("mark.doliner@gmail.com/Te/st@12@//345", true, false),
- array("ããã©@conference.jabber.org", true, true),
- array("ã¾ããã¼ã@conference.jabber.org", true, true),
- array("mark.doliner@gmail.com/ã¾ããã¼ã", true, false),
- array("mark.doliner@gmail/stuff.org", true, false),
- array("stuart@nödåtXäYZ.se", true, true),
- array("stuart@nödÃ¥tXäYZ.se/ã¾ããã¼ã", true, false),
- array("mark.doliner@ããã©.org", true, true),
- array("nick@ã¾ã¤.ãããã¿.net", true, true),
- array("paul@10.0.42.230/s", true, false),
- array("paul@[::1]", true, true), /* IPv6 */
- array("paul@[2001:470:1f05:d58::2]", true, true),
- array("paul@[2001:470:1f05:d58::2]/foo", true, false),
- array("pa=ul@10.0.42.230", true, true),
- array("pa,ul@10.0.42.230", true, true),
-
- array("@gmail.com", false, false),
- array("@@gmail.com", false, false),
- array("mark.doliner@@gmail.com/Test12345", false, false),
- array("mark@doliner@gmail.com/Test12345", false, false),
- array("@gmail.com/Test@12345", false, false),
- array("/Test@12345", false, false),
- array("mark.doliner@", false, false),
- array("mark.doliner/", false, false),
- array("mark.doliner@gmail_stuff.org", false, false),
- array("mark.doliner@gmail[stuff.org", false, false),
- array("mark.doliner@gmail\\stuff.org", false, false),
- array("paul@[::1]124", false, false),
- array("paul@2[::1]124/as", false, false),
- array("paul@ã¾ã¤.ãããã¿/\x01", false, false),
-
- /*
- * RFC 3454 Section 6 reads, in part,
- * "If a string contains any RandALCat character, the
- * string MUST NOT contain any LCat character."
- * The character is U+066D (ARABIC FIVE POINTED STAR).
- */
- // Leaving this one commented out for the moment
- // as it shouldn't hurt anything for our purposes.
- //array("foo@example.com/ÙsimplexeÙ", false, false)
- );
- }
-
- static public function normalizationCases()
- {
- return array(
- // Borrowed from test_jabber_jutil.c in libpurple
- array('PaUL@DaRkRain42.org', 'paul@darkrain42.org'),
- array('PaUL@DaRkRain42.org/', 'paul@darkrain42.org'),
- array('PaUL@DaRkRain42.org/resource', 'paul@darkrain42.org'),
-
- // Also adapted from libpurple tests...
- array('Ф@darkrain42.org', 'Ñ@darkrain42.org'),
- array('paul@Ó¨arkrain.org', 'paul@Ó©arkrain.org'),
- );
- }
-
- static public function domainCheckCases()
- {
- return array(
- array('gmail.com', true, 'known SRV record'),
- array('jabber.org', true, 'known SRV record'),
- array('status.net', true, 'known SRV record'),
- array('status.leuksman.com', true, 'known no SRV record but valid domain'),
- );
- }
-
-
-}
-
-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
diff --git a/tests/sample-uploads/image.gif b/tests/sample-uploads/image.gif
deleted file mode 100644
index b636f4b8df..0000000000
Binary files a/tests/sample-uploads/image.gif and /dev/null differ
diff --git a/tests/sample-uploads/image.jpeg b/tests/sample-uploads/image.jpeg
deleted file mode 100644
index 21fcb5aef4..0000000000
Binary files a/tests/sample-uploads/image.jpeg and /dev/null differ
diff --git a/tests/sample-uploads/image.jpg b/tests/sample-uploads/image.jpg
deleted file mode 100644
index 21fcb5aef4..0000000000
Binary files a/tests/sample-uploads/image.jpg and /dev/null differ
diff --git a/tests/sample-uploads/image.png b/tests/sample-uploads/image.png
deleted file mode 100644
index 60cbcfd17f..0000000000
Binary files a/tests/sample-uploads/image.png and /dev/null differ
diff --git a/tests/sample-uploads/office.pdf b/tests/sample-uploads/office.pdf
deleted file mode 100644
index 670bc2343e..0000000000
Binary files a/tests/sample-uploads/office.pdf and /dev/null differ
diff --git a/tests/sample-uploads/presentation.odp b/tests/sample-uploads/presentation.odp
deleted file mode 100644
index 8dd3a428bc..0000000000
Binary files a/tests/sample-uploads/presentation.odp and /dev/null differ
diff --git a/tests/sample-uploads/presentation.otp b/tests/sample-uploads/presentation.otp
deleted file mode 100644
index 1927ee79dd..0000000000
Binary files a/tests/sample-uploads/presentation.otp and /dev/null differ
diff --git a/tests/sample-uploads/presentation.pot b/tests/sample-uploads/presentation.pot
deleted file mode 100644
index f5124ffa2b..0000000000
Binary files a/tests/sample-uploads/presentation.pot and /dev/null differ
diff --git a/tests/sample-uploads/presentation.potm b/tests/sample-uploads/presentation.potm
deleted file mode 100644
index ade1bcb10f..0000000000
Binary files a/tests/sample-uploads/presentation.potm and /dev/null differ
diff --git a/tests/sample-uploads/presentation.ppt b/tests/sample-uploads/presentation.ppt
deleted file mode 100644
index f5124ffa2b..0000000000
Binary files a/tests/sample-uploads/presentation.ppt and /dev/null differ
diff --git a/tests/sample-uploads/presentation.pptx b/tests/sample-uploads/presentation.pptx
deleted file mode 100644
index 21ea61a159..0000000000
Binary files a/tests/sample-uploads/presentation.pptx and /dev/null differ
diff --git a/tests/sample-uploads/spreadsheet.ods b/tests/sample-uploads/spreadsheet.ods
deleted file mode 100644
index 7b43e75075..0000000000
Binary files a/tests/sample-uploads/spreadsheet.ods and /dev/null differ
diff --git a/tests/sample-uploads/spreadsheet.ots b/tests/sample-uploads/spreadsheet.ots
deleted file mode 100644
index 5f830e6def..0000000000
Binary files a/tests/sample-uploads/spreadsheet.ots and /dev/null differ
diff --git a/tests/sample-uploads/spreadsheet.xls b/tests/sample-uploads/spreadsheet.xls
deleted file mode 100644
index 2d470e6871..0000000000
Binary files a/tests/sample-uploads/spreadsheet.xls and /dev/null differ
diff --git a/tests/sample-uploads/spreadsheet.xlsx b/tests/sample-uploads/spreadsheet.xlsx
deleted file mode 100644
index b97a551f86..0000000000
Binary files a/tests/sample-uploads/spreadsheet.xlsx and /dev/null differ
diff --git a/tests/sample-uploads/spreadsheet.xlt b/tests/sample-uploads/spreadsheet.xlt
deleted file mode 100644
index 980423b20f..0000000000
Binary files a/tests/sample-uploads/spreadsheet.xlt and /dev/null differ
diff --git a/tests/sample-uploads/wordproc.doc b/tests/sample-uploads/wordproc.doc
deleted file mode 100644
index 81c5e34c6c..0000000000
Binary files a/tests/sample-uploads/wordproc.doc and /dev/null differ
diff --git a/tests/sample-uploads/wordproc.docx b/tests/sample-uploads/wordproc.docx
deleted file mode 100644
index 04ea3c3ec1..0000000000
Binary files a/tests/sample-uploads/wordproc.docx and /dev/null differ
diff --git a/tests/sample-uploads/wordproc.odt b/tests/sample-uploads/wordproc.odt
deleted file mode 100644
index fa6fe5e9ff..0000000000
Binary files a/tests/sample-uploads/wordproc.odt and /dev/null differ
diff --git a/tests/sample-uploads/wordproc.ott b/tests/sample-uploads/wordproc.ott
deleted file mode 100644
index 99ca8c0684..0000000000
Binary files a/tests/sample-uploads/wordproc.ott and /dev/null differ
diff --git a/tests/sample-uploads/wordproc.rtf b/tests/sample-uploads/wordproc.rtf
deleted file mode 100644
index aad2c4605e..0000000000
--- a/tests/sample-uploads/wordproc.rtf
+++ /dev/null
@@ -1,16 +0,0 @@
-{\rtf1\ansi\deff0\adeflang1025
-{\fonttbl{\f0\froman\fprq2\fcharset128 Times New Roman;}{\f1\froman\fprq2\fcharset128 Times New Roman;}{\f2\fswiss\fprq2\fcharset128 Arial;}{\f3\fnil\fprq2\fcharset128 DejaVu Sans;}}
-{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
-{\stylesheet{\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\snext1 Normal;}
-{\s2\sb240\sa120\keepn\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\afs28\lang1081\ltrch\dbch\langfe2052\hich\f2\fs28\lang1033\loch\f2\fs28\lang1033\sbasedon1\snext3 Heading;}
-{\s3\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon1\snext3 Body Text;}
-{\s4\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon3\snext4 List;}
-{\s5\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ai\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\i\loch\f0\fs24\lang1033\i\sbasedon1\snext5 caption;}
-{\s6\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033\sbasedon1\snext6 Index;}
-}
-{\info{\author Brion }{\creatim\yr2010\mo5\dy10\hr15\min2}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment StarWriter}{\vern3200}}\deftab709
-{\*\pgdsctbl
-{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Standard;}}
-\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
-\pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af3\afs24\lang1081\ltrch\dbch\af3\langfe2052\hich\f0\fs24\lang1033\loch\f0\fs24\lang1033
-\par }
\ No newline at end of file