[CORE] Make tests great gain
64
composer.lock
generated
@ -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",
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @param ... any remaining arguments will be appended to call-time params
|
||||
* @return callback
|
||||
*/
|
||||
function callable_left_curry($fn) {
|
||||
function callableLeftCurry($fn) {
|
||||
$extra_args = func_get_args();
|
||||
array_shift($extra_args);
|
||||
return function() use ($fn, $extra_args) {
|
@ -1,25 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008-2010, StatusNet, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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';
|
||||
|
||||
|
@ -1,35 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* utilities for defining and running event handlers
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Event
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 <evan@status.net>
|
||||
* @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 */
|
||||
|
@ -1,24 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2009-2010 StatusNet, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
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)
|
||||
|
@ -1,34 +1,33 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* Utility functions for i18n
|
||||
*
|
||||
* @category I18n
|
||||
* @package GNU social
|
||||
* @author Matthew Gregg <matthew.gregg@gmail.com>
|
||||
* @author Ciaran Gultnieks <ciaran@ciarang.com>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @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.
|
||||
|
@ -1,35 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Utility class for plugins
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Plugin
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
exit(1);
|
||||
}
|
||||
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 <evan@status.net>
|
||||
* @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()
|
||||
|
@ -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)
|
||||
{
|
||||
|
26
phpunit.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
<testsuites>
|
||||
<testsuite name="Core">
|
||||
<directory suffix="Test.php">./tests/Core</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Media">
|
||||
<directory suffix="Test.php">./tests/Media</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="QUEUE_DRIVER" value="sync"/>
|
||||
<env name="MAIL_DRIVER" value="array"/>
|
||||
</php>
|
||||
</phpunit>
|
@ -1,19 +1,49 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
namespace Tests\Unit;
|
||||
|
||||
if (!defined('INSTALLDIR')) {
|
||||
define('INSTALLDIR', dirname(dirname(__DIR__)));
|
||||
}
|
||||
if (!defined('PUBLICDIR')) {
|
||||
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
define('GNUSOCIAL', true);
|
||||
}
|
||||
if (!defined('STATUSNET')) { // Compatibility
|
||||
define('STATUSNET', true);
|
||||
}
|
||||
|
||||
// XXX: we should probably have some common source for this stuff
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
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';
|
||||
|
||||
class ActivityGenerationTests extends PHPUnit_Framework_TestCase
|
||||
final class ActivityGenerationTests extends TestCase
|
||||
{
|
||||
static $author1 = null;
|
||||
static $author2 = null;
|
||||
@ -558,7 +588,8 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
|
||||
$xml .= ' xmlns:statusnet="http://status.net/schema/api/1/"';
|
||||
}
|
||||
$xml .= '>' . "\n" . $entry . "\n" . '</feed>' . "\n";
|
||||
$doc = DOMDocument::loadXML($xml);
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadXML($xml);
|
||||
$feed = $doc->documentElement;
|
||||
$entries = $feed->getElementsByTagName('entry');
|
||||
|
@ -1,24 +1,48 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
namespace Tests\Unit;
|
||||
|
||||
if (!defined('INSTALLDIR')) {
|
||||
define('INSTALLDIR', dirname(dirname(__DIR__)));
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
define('GNUSOCIAL', true);
|
||||
}
|
||||
if (!defined('STATUSNET')) { // Compatibility
|
||||
define('STATUSNET', true);
|
||||
}
|
||||
|
||||
// XXX: we should probably have some common source for this stuff
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
use Activity;
|
||||
use ActivityObject;
|
||||
use ActivityUtils;
|
||||
use ActivityVerb;
|
||||
use DOMDocument;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
final class ActivityParseTests extends TestCase
|
||||
{
|
||||
|
||||
public function testMastodonRetweet() {
|
||||
public function testMastodonRetweet()
|
||||
{
|
||||
global $_mastodon_retweet;
|
||||
$dom = DOMDocument::loadXML($_mastodon_retweet);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_mastodon_retweet);
|
||||
$feed = $dom->documentElement;
|
||||
$entries = $feed->getElementsByTagName('entry');
|
||||
$entry = $entries->item(0);
|
||||
@ -30,9 +54,11 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($object->verb, ActivityVerb::POST);
|
||||
}
|
||||
|
||||
public function testGSReweet() {
|
||||
public function testGSReweet()
|
||||
{
|
||||
global $_gs_retweet;
|
||||
$dom = DOMDocument::loadXML($_gs_retweet);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_gs_retweet);
|
||||
$feed = $dom->documentElement;
|
||||
$entries = $feed->getElementsByTagName('entry');
|
||||
$entry = $entries->item(0);
|
||||
@ -47,7 +73,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
public function testExample1()
|
||||
{
|
||||
global $_example1;
|
||||
$dom = DOMDocument::loadXML($_example1);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_example1);
|
||||
$act = new Activity($dom->documentElement);
|
||||
|
||||
$this->assertFalse(empty($act));
|
||||
@ -65,7 +92,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
public function testExample2()
|
||||
{
|
||||
global $_example2;
|
||||
$dom = DOMDocument::loadXML($_example2);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_example2);
|
||||
$act = new Activity($dom->documentElement);
|
||||
|
||||
$this->assertFalse(empty($act));
|
||||
@ -77,7 +105,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
public function testExample3()
|
||||
{
|
||||
global $_example3;
|
||||
$dom = DOMDocument::loadXML($_example3);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_example3);
|
||||
|
||||
$feed = $dom->documentElement;
|
||||
|
||||
@ -116,7 +145,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
public function testExample4()
|
||||
{
|
||||
global $_example4;
|
||||
$dom = DOMDocument::loadXML($_example4);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_example4);
|
||||
|
||||
$entry = $dom->documentElement;
|
||||
|
||||
@ -142,7 +172,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
public function testExample5()
|
||||
{
|
||||
global $_example5;
|
||||
$dom = DOMDocument::loadXML($_example5);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_example5);
|
||||
|
||||
$feed = $dom->documentElement;
|
||||
|
||||
@ -186,7 +217,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
global $_example6;
|
||||
|
||||
$dom = DOMDocument::loadXML($_example6);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_example6);
|
||||
|
||||
$rss = $dom->documentElement;
|
||||
|
||||
@ -217,7 +249,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
global $_example7;
|
||||
|
||||
$dom = DOMDocument::loadXML($_example7);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_example7);
|
||||
|
||||
$rss = $dom->documentElement;
|
||||
|
||||
@ -262,7 +295,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
public function testExample8()
|
||||
{
|
||||
global $_example8;
|
||||
$dom = DOMDocument::loadXML($_example8);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_example8);
|
||||
|
||||
$feed = $dom->documentElement;
|
||||
|
||||
@ -375,7 +409,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
"<title>Atom content tests</title>" .
|
||||
$source .
|
||||
"</entry>";
|
||||
$dom = DOMDocument::loadXML($xml);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($xml);
|
||||
$act = new Activity($dom->documentElement);
|
||||
|
||||
$this->assertFalse(empty($act));
|
||||
@ -404,7 +439,8 @@ class ActivityParseTests extends PHPUnit_Framework_TestCase
|
||||
"<title>RSS content tests</title>" .
|
||||
$source .
|
||||
"</item>";
|
||||
$dom = DOMDocument::loadXML($xml);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($xml);
|
||||
$act = new Activity($dom->documentElement);
|
||||
|
||||
$this->assertFalse(empty($act));
|
91
tests/Core/CallableLeftCurryTest.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,21 +1,44 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
namespace Tests\Unit;
|
||||
|
||||
if (!defined('INSTALLDIR')) {
|
||||
define('INSTALLDIR', dirname(dirname(__DIR__)));
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
define('GNUSOCIAL', true);
|
||||
}
|
||||
if (!defined('STATUSNET')) { // Compatibility
|
||||
define('STATUSNET', true);
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
use CommandInterpreter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class CommandInterpreterTest extends PHPUnit_Framework_TestCase
|
||||
final class CommandInterpreterTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @dataProvider commandInterpreterCases
|
||||
* @param $input
|
||||
* @param $expectedType
|
||||
* @param string $comment
|
||||
*/
|
||||
public function testCommandInterpreter($input, $expectedType, $comment = '')
|
||||
{
|
83
tests/Core/HashTagDetectionTests.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span> people'),
|
||||
array('"#hello" people',
|
||||
'"#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>" people'),
|
||||
array('say "#hello" people',
|
||||
'say "#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>" people'),
|
||||
array('say (#hello) people',
|
||||
'say (#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>) people'),
|
||||
array('say [#hello] people',
|
||||
'say [#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>] people'),
|
||||
array('say {#hello} people',
|
||||
'say {#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>} people'),
|
||||
array('say \'#hello\' people',
|
||||
'say \'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>\' people'),
|
||||
|
||||
// Unicode legit letters
|
||||
array('#éclair yummy',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('éclair'))) . '" rel="tag">éclair</a></span> yummy'),
|
||||
array('#维基百科 zh.wikipedia!',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span> zh.wikipedia!'),
|
||||
array('#Россия russia',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('Россия'))) . '" rel="tag">Россия</a></span> russia'),
|
||||
|
||||
// Unicode punctuators -- the ideographic "," separates the tag, just as "," does
|
||||
array('#维基百科,zh.wikipedia!',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span>,zh.wikipedia!'),
|
||||
array('#维基百科,zh.wikipedia!',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span>,zh.wikipedia!'),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
124
tests/Core/LocationTest.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
156
tests/Core/NicknameTest.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
59
tests/Core/TagURITest.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
377
tests/Core/URLDetectionTest.php
Normal file
@ -0,0 +1,377 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" title="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
|
||||
array('http://127.0.0.1',
|
||||
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://127.0.0.1</a>'),
|
||||
array('http://[::1]:99/test.php',
|
||||
'<a href="http://[::1]:99/test.php" title="http://[::1]:99/test.php" rel="nofollow external">http://[::1]:99/test.php</a>'),
|
||||
array('http://::1/test.php',
|
||||
'<a href="http://::1/test.php" title="http://::1/test.php" rel="nofollow external">http://::1/test.php</a>'),
|
||||
array('http://::1',
|
||||
'<a href="http://::1/" title="http://::1/" rel="nofollow external">http://::1</a>'),
|
||||
array('http://127.0.0.1',
|
||||
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://127.0.0.1</a>'),
|
||||
array('http://example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
|
||||
array('http://example.com.',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
|
||||
array('/var/lib/example.so',
|
||||
'/var/lib/example.so'),
|
||||
array('example',
|
||||
'example'),
|
||||
array('mailto:user@example.com',
|
||||
'<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">mailto:user@example.com</a>'),
|
||||
array('mailto:user@example.com?subject=test',
|
||||
'<a href="mailto:user@example.com?subject=test" title="mailto:user@example.com?subject=test" rel="nofollow external">mailto:user@example.com?subject=test</a>'),
|
||||
array('xmpp:user@example.com',
|
||||
'<a href="xmpp:user@example.com" title="xmpp:user@example.com" rel="nofollow external">xmpp:user@example.com</a>'),
|
||||
array('#example',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example'))) . '" rel="tag">example</a></span>'),
|
||||
array('#example.com',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example.com'))) . '" rel="tag">example.com</a></span>'),
|
||||
array('#.net',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('.net'))) . '" rel="tag">.net</a></span>'),
|
||||
array('http://example',
|
||||
'<a href="http://example/" title="http://example/" rel="nofollow external">http://example</a>'),
|
||||
array('http://3xampl3',
|
||||
'<a href="http://3xampl3/" title="http://3xampl3/" rel="nofollow external">http://3xampl3</a>'),
|
||||
array('http://example/',
|
||||
'<a href="http://example/" title="http://example/" rel="nofollow external">http://example/</a>'),
|
||||
array('http://example/path',
|
||||
'<a href="http://example/path" title="http://example/path" rel="nofollow external">http://example/path</a>'),
|
||||
array('http://example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
|
||||
array('https://example.com',
|
||||
'<a href="https://example.com/" title="https://example.com/" rel="nofollow external">https://example.com</a>'),
|
||||
array('ftp://example.com',
|
||||
'<a href="ftp://example.com/" title="ftp://example.com/" rel="nofollow external">ftp://example.com</a>'),
|
||||
array('ftps://example.com',
|
||||
'<a href="ftps://example.com/" title="ftps://example.com/" rel="nofollow external">ftps://example.com</a>'),
|
||||
array('http://user@example.com',
|
||||
'<a href="http://@example.com/" title="http://@example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://user@example.com</a>'),
|
||||
array('http://user:pass@example.com',
|
||||
'<a href="http://@example.com/" title="http://@example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://user:pass@example.com</a>'),
|
||||
array('http://example.com:8080',
|
||||
'<a href="http://example.com:8080/" title="http://example.com:8080/" rel="nofollow external">http://example.com:8080</a>'),
|
||||
array('http://example.com:8080/test.php',
|
||||
'<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">http://example.com:8080/test.php</a>'),
|
||||
array('http://www.example.com',
|
||||
'<a href="http://www.example.com/" title="http://www.example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://www.example.com</a>'),
|
||||
array('http://example.com/',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/</a>'),
|
||||
array('http://example.com/path',
|
||||
'<a href="http://example.com/path" title="http://example.com/path" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path</a>'),
|
||||
array('http://example.com/path.html',
|
||||
'<a href="http://example.com/path.html" title="http://example.com/path.html" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.html</a>'),
|
||||
array('http://example.com/path.html#fragment',
|
||||
'<a href="http://example.com/path.html#fragment" title="http://example.com/path.html#fragment" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.html#fragment</a>'),
|
||||
array('http://example.com/path.php?foo=bar&bar=foo',
|
||||
'<a href="http://example.com/path.php?foo=bar&bar=foo" title="http://example.com/path.php?foo=bar&bar=foo" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.php?foo=bar&bar=foo</a>'),
|
||||
array('http://example.com.',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
|
||||
array('http://müllärör.de',
|
||||
'<a href="http://müllärör.de/" title="http://müllärör.de/" rel="nofollow external">http://müllärör.de</a>'),
|
||||
array('http://ﺱﺲﺷ.com',
|
||||
'<a href="http://ﺱﺲﺷ.com/" title="http://ﺱﺲﺷ.com/" rel="nofollow external">http://ﺱﺲﺷ.com</a>'),
|
||||
array('http://сделаткартинки.com',
|
||||
'<a href="http://сделаткартинки.com/" title="http://сделаткартинки.com/" rel="nofollow external">http://сделаткартинки.com</a>'),
|
||||
array('http://tūdaliņ.lv',
|
||||
'<a href="http://tūdaliņ.lv/" title="http://tūdaliņ.lv/" rel="nofollow external">http://tūdaliņ.lv</a>'),
|
||||
array('http://brændendekærlighed.com',
|
||||
'<a href="http://brændendekærlighed.com/" title="http://brændendekærlighed.com/" rel="nofollow external">http://brændendekærlighed.com</a>'),
|
||||
array('http://あーるいん.com',
|
||||
'<a href="http://あーるいん.com/" title="http://あーるいん.com/" rel="nofollow external">http://あーるいん.com</a>'),
|
||||
array('http://예비교사.com',
|
||||
'<a href="http://예비교사.com/" title="http://예비교사.com/" rel="nofollow external">http://예비교사.com</a>'),
|
||||
array('http://example.com.',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
|
||||
array('http://example.com?',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>?'),
|
||||
array('http://example.com!',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>!'),
|
||||
array('http://example.com,',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>,'),
|
||||
array('http://example.com;',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>;'),
|
||||
array('http://example.com:',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>:'),
|
||||
array('\'http://example.com\'',
|
||||
'\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>\''),
|
||||
array('"http://example.com"',
|
||||
'"<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>"'),
|
||||
array('"http://example.com/"',
|
||||
'"<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/</a>"'),
|
||||
array('http://example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
|
||||
array('(http://example.com)',
|
||||
'(<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>)'),
|
||||
array('[http://example.com]',
|
||||
'[<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>]'),
|
||||
array('<http://example.com>',
|
||||
'<<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>>'),
|
||||
array('http://example.com/path/(foo)/bar',
|
||||
'<a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo)/bar'),
|
||||
array('http://example.com/path/[foo]/bar',
|
||||
'<a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>[foo]/bar'),
|
||||
array('http://example.com/path/foo/(bar)',
|
||||
'<a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar)'),
|
||||
//Not a valid url - urls cannot contain unencoded square brackets
|
||||
array('http://example.com/path/foo/[bar]',
|
||||
'<a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>[bar]'),
|
||||
array('Hey, check out my cool site http://example.com okay?',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a> okay?'),
|
||||
array('What about parens (e.g. http://example.com/path/foo/(bar))?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar))?'),
|
||||
array('What about parens (e.g. http://example.com/path/foo/(bar)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar)?'),
|
||||
array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(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. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo,bar)?'),
|
||||
array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
|
||||
'Unbalanced too (e.g. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>((((foo)/bar)?'),
|
||||
array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
|
||||
'Unbalanced too (e.g. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo))))/bar)?'),
|
||||
array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
|
||||
'Unbalanced too (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>((((bar)?'),
|
||||
array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
|
||||
'Unbalanced too (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(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',
|
||||
'<a href="http://www.flickr.com/photos/34807140@N05/3838905434" title="http://www.flickr.com/photos/34807140@N05/3838905434" rel="nofollow external noreferrer" class="attachment thumbnail" id="attachment-XXX">http://flickr.com/photos/34807140@N05/3838905434</a>'),
|
||||
);
|
||||
}
|
||||
|
||||
static public function linkifyProvider()
|
||||
{
|
||||
return array(
|
||||
//bare ip addresses are no longer supported
|
||||
array('127.0.0.1',
|
||||
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1:99',
|
||||
'<a href="http://127.0.0.1:99/" title="http://127.0.0.1:99/" rel="nofollow external">127.0.0.1:99</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/Name:test.php',
|
||||
'<a href="http://127.0.0.1/Name:test.php" title="http://127.0.0.1/Name:test.php" rel="nofollow external">127.0.0.1/Name:test.php</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/~test',
|
||||
'<a href="http://127.0.0.1/~test" title="http://127.0.0.1/~test" rel="nofollow external">127.0.0.1/~test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/+test',
|
||||
'<a href="http://127.0.0.1/+test" title="http://127.0.0.1/+test" rel="nofollow external">127.0.0.1/+test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/$test',
|
||||
'<a href="http://127.0.0.1/$test" title="http://127.0.0.1/$test" rel="nofollow external">127.0.0.1/$test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/\'test',
|
||||
'<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="nofollow external">127.0.0.1/\'test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/"test',
|
||||
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1/</a>"test',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/test"test',
|
||||
'<a href="http://127.0.0.1/test" title="http://127.0.0.1/test" rel="nofollow external">127.0.0.1/test</a>"test',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/-test',
|
||||
'<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="nofollow external">127.0.0.1/-test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/_test',
|
||||
'<a href="http://127.0.0.1/_test" title="http://127.0.0.1/_test" rel="nofollow external">127.0.0.1/_test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/!test',
|
||||
'<a href="http://127.0.0.1/!test" title="http://127.0.0.1/!test" rel="nofollow external">127.0.0.1/!test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/*test',
|
||||
'<a href="http://127.0.0.1/*test" title="http://127.0.0.1/*test" rel="nofollow external">127.0.0.1/*test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/test%20stuff',
|
||||
'<a href="http://127.0.0.1/test%20stuff" title="http://127.0.0.1/test%20stuff" rel="nofollow external">127.0.0.1/test%20stuff</a>',
|
||||
'bare_ipv4'),
|
||||
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
|
||||
'<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="nofollow external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>',
|
||||
'bare_ipv6'),
|
||||
array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
|
||||
'<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" title="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="nofollow external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>',
|
||||
'bare_ipv6'),
|
||||
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
|
||||
'<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="nofollow external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>',
|
||||
'bare_ipv6'),
|
||||
array('example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
|
||||
'bare_domains'),
|
||||
array('flickr.com/photos/34807140@N05/3838905434',
|
||||
'<a href="http://flickr.com/photos/34807140@N05/3838905434" title="http://flickr.com/photos/34807140@N05/3838905434" class="attachment thumbnail" id="attachment-XXX" rel="nofollow external">flickr.com/photos/34807140@N05/3838905434</a>',
|
||||
'bare_domains'),
|
||||
array('What about parens (e.g. example.com/path/foo/(bar))?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>)?',
|
||||
'bare_domains'),
|
||||
array('What about parens (e.g. example.com/path/foo/(bar)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>?',
|
||||
'bare_domains'),
|
||||
array('What about parens (e.g. example.com/path/foo/(bar).)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>.?',
|
||||
'bare_domains'),
|
||||
array('What about parens (e.g. example.com/path/(foo,bar)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="nofollow external">example.com/path/(foo,bar)</a>?',
|
||||
'bare_domains'),
|
||||
array('example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
|
||||
'bare_domains'),
|
||||
array('example.org',
|
||||
'<a href="http://example.org/" title="http://example.org/" rel="nofollow external">example.org</a>',
|
||||
'bare_domains'),
|
||||
array('example.co.uk',
|
||||
'<a href="http://example.co.uk/" title="http://example.co.uk/" rel="nofollow external">example.co.uk</a>',
|
||||
'bare_domains'),
|
||||
array('www.example.co.uk',
|
||||
'<a href="http://www.example.co.uk/" title="http://www.example.co.uk/" rel="nofollow external">www.example.co.uk</a>',
|
||||
'bare_domains'),
|
||||
array('farm1.images.example.co.uk',
|
||||
'<a href="http://farm1.images.example.co.uk/" title="http://farm1.images.example.co.uk/" rel="nofollow external">farm1.images.example.co.uk</a>',
|
||||
'bare_domains'),
|
||||
array('example.museum',
|
||||
'<a href="http://example.museum/" title="http://example.museum/" rel="nofollow external">example.museum</a>',
|
||||
'bare_domains'),
|
||||
array('example.travel',
|
||||
'<a href="http://example.travel/" title="http://example.travel/" rel="nofollow external">example.travel</a>',
|
||||
'bare_domains'),
|
||||
array('example.com.',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.',
|
||||
'bare_domains'),
|
||||
array('example.com?',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>?',
|
||||
'bare_domains'),
|
||||
array('example.com!',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>!',
|
||||
'bare_domains'),
|
||||
array('example.com,',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>,',
|
||||
'bare_domains'),
|
||||
array('example.com;',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>;',
|
||||
'bare_domains'),
|
||||
array('example.com:',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>:',
|
||||
'bare_domains'),
|
||||
array('\'example.com\'',
|
||||
'\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>\'',
|
||||
'bare_domains'),
|
||||
array('"example.com"',
|
||||
'"<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>"',
|
||||
'bare_domains'),
|
||||
array('example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
|
||||
'bare_domains'),
|
||||
array('(example.com)',
|
||||
'(<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>)',
|
||||
'bare_domains'),
|
||||
array('[example.com]',
|
||||
'[<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>]',
|
||||
'bare_domains'),
|
||||
array('<example.com>',
|
||||
'<<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>>',
|
||||
'bare_domains'),
|
||||
array('Hey, check out my cool site example.com okay?',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a> okay?',
|
||||
'bare_domains'),
|
||||
array('Hey, check out my cool site example.com.I made it.',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.I made it.',
|
||||
'bare_domains'),
|
||||
array('Hey, check out my cool site example.com.Funny thing...',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.Funny thing...',
|
||||
'bare_domains'),
|
||||
array('Hey, check out my cool site example.com.You will love it.',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.You will love it.',
|
||||
'bare_domains'),
|
||||
array('example.com:8080/test.php',
|
||||
'<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">example.com:8080/test.php</a>',
|
||||
'bare_domains'),
|
||||
array('user_name+other@example.com',
|
||||
'<a href="mailto:user_name+other@example.com" title="mailto:user_name+other@example.com" rel="nofollow external">user_name+other@example.com</a>',
|
||||
'bare_domains'),
|
||||
array('user@example.com',
|
||||
'<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">user@example.com</a>',
|
||||
'bare_domains'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
58
tests/Core/UUIDTest.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,45 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
namespace Tests\Unit;
|
||||
|
||||
if (!defined('INSTALLDIR')) {
|
||||
define('INSTALLDIR', dirname(dirname(__DIR__)));
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
define('GNUSOCIAL', true);
|
||||
}
|
||||
if (!defined('STATUSNET')) { // Compatibility
|
||||
define('STATUSNET', true);
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
use Activity;
|
||||
use ActivityObject;
|
||||
use DOMDocument;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class UserFeedParseTests extends PHPUnit_Framework_TestCase
|
||||
final class UserFeedParseTests extends TestCase
|
||||
{
|
||||
public function testFeed1()
|
||||
{
|
||||
global $_testfeed1;
|
||||
$dom = DOMDocument::loadXML($_testfeed1);
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($_testfeed1);
|
||||
$this->assertFalse(empty($dom));
|
||||
|
||||
$entries = $dom->getElementsByTagName('entry');
|
@ -1,17 +1,38 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
namespace Tests\Unit;
|
||||
|
||||
if (!defined('INSTALLDIR')) {
|
||||
define('INSTALLDIR', dirname(dirname(__DIR__)));
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
define('GNUSOCIAL', true);
|
||||
}
|
||||
if (!defined('STATUSNET')) { // Compatibility
|
||||
define('STATUSNET', true);
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use User;
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class UserRightsTest extends PHPUnit_Framework_TestCase
|
||||
final class UserRightsTest extends TestCase
|
||||
{
|
||||
protected $user = null;
|
||||
|
||||
@ -52,7 +73,7 @@ class UserRightsTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider standardRoles
|
||||
*
|
||||
* @param $role
|
||||
*/
|
||||
|
||||
function testUngrantedRole($role)
|
||||
@ -62,7 +83,7 @@ class UserRightsTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider standardRoles
|
||||
*
|
||||
* @param $role
|
||||
*/
|
||||
|
||||
function testGrantedRole($role)
|
@ -1,20 +1,40 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
namespace Tests\Unit;
|
||||
|
||||
if (!defined('INSTALLDIR')) {
|
||||
define('INSTALLDIR', dirname(dirname(__DIR__)));
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
define('GNUSOCIAL', true);
|
||||
}
|
||||
if (!defined('STATUSNET')) { // Compatibility
|
||||
define('STATUSNET', true);
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
mb_internal_encoding('UTF-8'); // @fixme this probably belongs in common.php?
|
||||
use GNUsocial;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use XmppPlugin;
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
require_once INSTALLDIR . '/plugins/Xmpp/XmppPlugin.php';
|
||||
|
||||
class XmppValidateTest extends PHPUnit_Framework_TestCase
|
||||
final class XmppValidateTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
@ -22,9 +42,12 @@ class XmppValidateTest extends PHPUnit_Framework_TestCase
|
||||
$this->markTestSkipped('XmppPlugin is not enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validationCases
|
||||
*
|
||||
* @param $jid
|
||||
* @param $validFull
|
||||
* @param $validBase
|
||||
*/
|
||||
public function testValidate($jid, $validFull, $validBase)
|
||||
{
|
||||
@ -36,7 +59,8 @@ class XmppValidateTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider normalizationCases
|
||||
*
|
||||
* @param $jid
|
||||
* @param $expected
|
||||
*/
|
||||
public function testNormalize($jid, $expected)
|
||||
{
|
||||
@ -46,6 +70,9 @@ class XmppValidateTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider domainCheckCases()
|
||||
* @param $domain
|
||||
* @param $expected
|
||||
* @param $note
|
||||
*/
|
||||
public function testDomainCheck($domain, $expected, $note)
|
||||
{
|
||||
@ -153,7 +180,8 @@ class XmppValidateTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
}
|
||||
|
||||
class TestXmppPlugin extends XmppPlugin {
|
||||
class TestXmppPlugin extends XmppPlugin
|
||||
{
|
||||
public function checkDomain($domain)
|
||||
{
|
||||
return parent::checkDomain($domain);
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class CurryTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*
|
||||
*/
|
||||
public function testProduction($callback, $curry_params, $call_params, $expected)
|
||||
{
|
||||
$params = array_merge(array($callback), $curry_params);
|
||||
$curried = call_user_func_array('callable_left_curry', $params);
|
||||
$result = call_user_func_array($curried, $call_params);
|
||||
$this->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;
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class HashTagDetectionTests extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*
|
||||
*/
|
||||
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',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span> people'),
|
||||
array('"#hello" people',
|
||||
'"#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>" people'),
|
||||
array('say "#hello" people',
|
||||
'say "#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>" people'),
|
||||
array('say (#hello) people',
|
||||
'say (#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>) people'),
|
||||
array('say [#hello] people',
|
||||
'say [#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>] people'),
|
||||
array('say {#hello} people',
|
||||
'say {#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>} people'),
|
||||
array('say \'#hello\' people',
|
||||
'say \'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('hello'))) . '" rel="tag">hello</a></span>\' people'),
|
||||
|
||||
// Unicode legit letters
|
||||
array('#éclair yummy',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('éclair'))) . '" rel="tag">éclair</a></span> yummy'),
|
||||
array('#维基百科 zh.wikipedia!',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span> zh.wikipedia!'),
|
||||
array('#Россия russia',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('Россия'))) . '" rel="tag">Россия</a></span> russia'),
|
||||
|
||||
// Unicode punctuators -- the ideographic "," separates the tag, just as "," does
|
||||
array('#维基百科,zh.wikipedia!',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span>,zh.wikipedia!'),
|
||||
array('#维基百科,zh.wikipedia!',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('维基百科'))) . '" rel="tag">维基百科</a></span>,zh.wikipedia!'),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
// Make sure this is loaded
|
||||
// XXX: how to test other plugins...?
|
||||
|
||||
addPlugin('Geonames');
|
||||
|
||||
class LocationTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @dataProvider locationNames
|
||||
*/
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,40 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
namespace Tests\Unit;
|
||||
|
||||
if (!defined('INSTALLDIR')) {
|
||||
define('INSTALLDIR', dirname(dirname(__DIR__)));
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) {
|
||||
define('GNUSOCIAL', true);
|
||||
}
|
||||
if (!defined('STATUSNET')) { // Compatibility
|
||||
define('STATUSNET', true);
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
use ClientException;
|
||||
use Exception;
|
||||
use MediaFile;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ServerException;
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class MediaFileTest extends PHPUnit_Framework_TestCase
|
||||
final class MediaFileTest extends TestCase
|
||||
{
|
||||
|
||||
public function setup()
|
||||
@ -27,7 +50,10 @@ class MediaFileTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider fileTypeCases
|
||||
*
|
||||
* @param $filename
|
||||
* @param $expectedType
|
||||
* @throws ClientException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function testMimeType($filename, $expectedType)
|
||||
{
|
||||
@ -41,7 +67,10 @@ class MediaFileTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider fileTypeCases
|
||||
*
|
||||
* @param $filename
|
||||
* @param $expectedType
|
||||
* @throws ClientException
|
||||
* @throws ServerException
|
||||
*/
|
||||
public function testUploadedMimeType($filename, $expectedType)
|
||||
{
|
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 159 B |
@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
/**
|
||||
* Test cases for nickname validity and normalization.
|
||||
*/
|
||||
class NicknameTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Basic test using Nickname::normalize()
|
||||
*
|
||||
* @dataProvider provider
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
$config['site']['server'] = 'example.net';
|
||||
$config['site']['path'] = '/apps/statusnet';
|
||||
|
||||
class TagURITest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*/
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
@ -1,355 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class URLDetectionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*
|
||||
*/
|
||||
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
|
||||
*
|
||||
*/
|
||||
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 <a href="http://www.somesite.com/xyz/35637563@N00/52803365/" title="http://www.somesite.com/xyz/35637563@N00/52803365/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://www.somesite.com/xyz/35637563@N00/52803365/</a> link'),
|
||||
array('http://127.0.0.1',
|
||||
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://127.0.0.1</a>'),
|
||||
array('http://[::1]:99/test.php',
|
||||
'<a href="http://[::1]:99/test.php" title="http://[::1]:99/test.php" rel="nofollow external">http://[::1]:99/test.php</a>'),
|
||||
array('http://::1/test.php',
|
||||
'<a href="http://::1/test.php" title="http://::1/test.php" rel="nofollow external">http://::1/test.php</a>'),
|
||||
array('http://::1',
|
||||
'<a href="http://::1/" title="http://::1/" rel="nofollow external">http://::1</a>'),
|
||||
array('http://127.0.0.1',
|
||||
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://127.0.0.1</a>'),
|
||||
array('http://example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
|
||||
array('http://example.com.',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
|
||||
array('/var/lib/example.so',
|
||||
'/var/lib/example.so'),
|
||||
array('example',
|
||||
'example'),
|
||||
array('mailto:user@example.com',
|
||||
'<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">mailto:user@example.com</a>'),
|
||||
array('mailto:user@example.com?subject=test',
|
||||
'<a href="mailto:user@example.com?subject=test" title="mailto:user@example.com?subject=test" rel="nofollow external">mailto:user@example.com?subject=test</a>'),
|
||||
array('xmpp:user@example.com',
|
||||
'<a href="xmpp:user@example.com" title="xmpp:user@example.com" rel="nofollow external">xmpp:user@example.com</a>'),
|
||||
array('#example',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example'))) . '" rel="tag">example</a></span>'),
|
||||
array('#example.com',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('example.com'))) . '" rel="tag">example.com</a></span>'),
|
||||
array('#.net',
|
||||
'#<span class="tag"><a href="' . common_local_url('tag', array('tag' => common_canonical_tag('.net'))) . '" rel="tag">.net</a></span>'),
|
||||
array('http://example',
|
||||
'<a href="http://example/" title="http://example/" rel="nofollow external">http://example</a>'),
|
||||
array('http://3xampl3',
|
||||
'<a href="http://3xampl3/" title="http://3xampl3/" rel="nofollow external">http://3xampl3</a>'),
|
||||
array('http://example/',
|
||||
'<a href="http://example/" title="http://example/" rel="nofollow external">http://example/</a>'),
|
||||
array('http://example/path',
|
||||
'<a href="http://example/path" title="http://example/path" rel="nofollow external">http://example/path</a>'),
|
||||
array('http://example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
|
||||
array('https://example.com',
|
||||
'<a href="https://example.com/" title="https://example.com/" rel="nofollow external">https://example.com</a>'),
|
||||
array('ftp://example.com',
|
||||
'<a href="ftp://example.com/" title="ftp://example.com/" rel="nofollow external">ftp://example.com</a>'),
|
||||
array('ftps://example.com',
|
||||
'<a href="ftps://example.com/" title="ftps://example.com/" rel="nofollow external">ftps://example.com</a>'),
|
||||
array('http://user@example.com',
|
||||
'<a href="http://@example.com/" title="http://@example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://user@example.com</a>'),
|
||||
array('http://user:pass@example.com',
|
||||
'<a href="http://@example.com/" title="http://@example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://user:pass@example.com</a>'),
|
||||
array('http://example.com:8080',
|
||||
'<a href="http://example.com:8080/" title="http://example.com:8080/" rel="nofollow external">http://example.com:8080</a>'),
|
||||
array('http://example.com:8080/test.php',
|
||||
'<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">http://example.com:8080/test.php</a>'),
|
||||
array('http://www.example.com',
|
||||
'<a href="http://www.example.com/" title="http://www.example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://www.example.com</a>'),
|
||||
array('http://example.com/',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/</a>'),
|
||||
array('http://example.com/path',
|
||||
'<a href="http://example.com/path" title="http://example.com/path" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path</a>'),
|
||||
array('http://example.com/path.html',
|
||||
'<a href="http://example.com/path.html" title="http://example.com/path.html" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.html</a>'),
|
||||
array('http://example.com/path.html#fragment',
|
||||
'<a href="http://example.com/path.html#fragment" title="http://example.com/path.html#fragment" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.html#fragment</a>'),
|
||||
array('http://example.com/path.php?foo=bar&bar=foo',
|
||||
'<a href="http://example.com/path.php?foo=bar&bar=foo" title="http://example.com/path.php?foo=bar&bar=foo" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path.php?foo=bar&bar=foo</a>'),
|
||||
array('http://example.com.',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
|
||||
array('http://müllärör.de',
|
||||
'<a href="http://müllärör.de/" title="http://müllärör.de/" rel="nofollow external">http://müllärör.de</a>'),
|
||||
array('http://ﺱﺲﺷ.com',
|
||||
'<a href="http://ﺱﺲﺷ.com/" title="http://ﺱﺲﺷ.com/" rel="nofollow external">http://ﺱﺲﺷ.com</a>'),
|
||||
array('http://сделаткартинки.com',
|
||||
'<a href="http://сделаткартинки.com/" title="http://сделаткартинки.com/" rel="nofollow external">http://сделаткартинки.com</a>'),
|
||||
array('http://tūdaliņ.lv',
|
||||
'<a href="http://tūdaliņ.lv/" title="http://tūdaliņ.lv/" rel="nofollow external">http://tūdaliņ.lv</a>'),
|
||||
array('http://brændendekærlighed.com',
|
||||
'<a href="http://brændendekærlighed.com/" title="http://brændendekærlighed.com/" rel="nofollow external">http://brændendekærlighed.com</a>'),
|
||||
array('http://あーるいん.com',
|
||||
'<a href="http://あーるいん.com/" title="http://あーるいん.com/" rel="nofollow external">http://あーるいん.com</a>'),
|
||||
array('http://예비교사.com',
|
||||
'<a href="http://예비교사.com/" title="http://예비교사.com/" rel="nofollow external">http://예비교사.com</a>'),
|
||||
array('http://example.com.',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>.'),
|
||||
array('http://example.com?',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>?'),
|
||||
array('http://example.com!',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>!'),
|
||||
array('http://example.com,',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>,'),
|
||||
array('http://example.com;',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>;'),
|
||||
array('http://example.com:',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>:'),
|
||||
array('\'http://example.com\'',
|
||||
'\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>\''),
|
||||
array('"http://example.com"',
|
||||
'"<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>"'),
|
||||
array('"http://example.com/"',
|
||||
'"<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/</a>"'),
|
||||
array('http://example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>'),
|
||||
array('(http://example.com)',
|
||||
'(<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>)'),
|
||||
array('[http://example.com]',
|
||||
'[<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>]'),
|
||||
array('<http://example.com>',
|
||||
'<<a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a>>'),
|
||||
array('http://example.com/path/(foo)/bar',
|
||||
'<a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo)/bar'),
|
||||
array('http://example.com/path/[foo]/bar',
|
||||
'<a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>[foo]/bar'),
|
||||
array('http://example.com/path/foo/(bar)',
|
||||
'<a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar)'),
|
||||
//Not a valid url - urls cannot contain unencoded square brackets
|
||||
array('http://example.com/path/foo/[bar]',
|
||||
'<a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>[bar]'),
|
||||
array('Hey, check out my cool site http://example.com okay?',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com</a> okay?'),
|
||||
array('What about parens (e.g. http://example.com/path/foo/(bar))?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar))?'),
|
||||
array('What about parens (e.g. http://example.com/path/foo/(bar)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(bar)?'),
|
||||
array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(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. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo,bar)?'),
|
||||
array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
|
||||
'Unbalanced too (e.g. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>((((foo)/bar)?'),
|
||||
array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
|
||||
'Unbalanced too (e.g. <a href="http://example.com/path/" title="http://example.com/path/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/</a>(foo))))/bar)?'),
|
||||
array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
|
||||
'Unbalanced too (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>((((bar)?'),
|
||||
array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
|
||||
'Unbalanced too (e.g. <a href="http://example.com/path/foo/" title="http://example.com/path/foo/" rel="nofollow external noreferrer" class="attachment" id="attachment-XXX">http://example.com/path/foo/</a>(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',
|
||||
'<a href="http://www.flickr.com/photos/34807140@N05/3838905434" title="http://www.flickr.com/photos/34807140@N05/3838905434" rel="nofollow external noreferrer" class="attachment thumbnail" id="attachment-XXX">http://flickr.com/photos/34807140@N05/3838905434</a>'),
|
||||
);
|
||||
}
|
||||
|
||||
static public function linkifyProvider()
|
||||
{
|
||||
return array(
|
||||
//bare ip addresses are no longer supported
|
||||
array('127.0.0.1',
|
||||
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1:99',
|
||||
'<a href="http://127.0.0.1:99/" title="http://127.0.0.1:99/" rel="nofollow external">127.0.0.1:99</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/Name:test.php',
|
||||
'<a href="http://127.0.0.1/Name:test.php" title="http://127.0.0.1/Name:test.php" rel="nofollow external">127.0.0.1/Name:test.php</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/~test',
|
||||
'<a href="http://127.0.0.1/~test" title="http://127.0.0.1/~test" rel="nofollow external">127.0.0.1/~test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/+test',
|
||||
'<a href="http://127.0.0.1/+test" title="http://127.0.0.1/+test" rel="nofollow external">127.0.0.1/+test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/$test',
|
||||
'<a href="http://127.0.0.1/$test" title="http://127.0.0.1/$test" rel="nofollow external">127.0.0.1/$test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/\'test',
|
||||
'<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="nofollow external">127.0.0.1/\'test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/"test',
|
||||
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="nofollow external">127.0.0.1/</a>"test',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/test"test',
|
||||
'<a href="http://127.0.0.1/test" title="http://127.0.0.1/test" rel="nofollow external">127.0.0.1/test</a>"test',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/-test',
|
||||
'<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="nofollow external">127.0.0.1/-test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/_test',
|
||||
'<a href="http://127.0.0.1/_test" title="http://127.0.0.1/_test" rel="nofollow external">127.0.0.1/_test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/!test',
|
||||
'<a href="http://127.0.0.1/!test" title="http://127.0.0.1/!test" rel="nofollow external">127.0.0.1/!test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/*test',
|
||||
'<a href="http://127.0.0.1/*test" title="http://127.0.0.1/*test" rel="nofollow external">127.0.0.1/*test</a>',
|
||||
'bare_ipv4'),
|
||||
array('127.0.0.1/test%20stuff',
|
||||
'<a href="http://127.0.0.1/test%20stuff" title="http://127.0.0.1/test%20stuff" rel="nofollow external">127.0.0.1/test%20stuff</a>',
|
||||
'bare_ipv4'),
|
||||
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
|
||||
'<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php" rel="nofollow external">2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php</a>',
|
||||
'bare_ipv6'),
|
||||
array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
|
||||
'<a href="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" title="http://[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php" rel="nofollow external">[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php</a>',
|
||||
'bare_ipv6'),
|
||||
array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
|
||||
'<a href="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" title="http://2001:4978:1b5:0:21d:e0ff:fe66:59ab/" rel="nofollow external">2001:4978:1b5:0:21d:e0ff:fe66:59ab</a>',
|
||||
'bare_ipv6'),
|
||||
array('example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
|
||||
'bare_domains'),
|
||||
array('flickr.com/photos/34807140@N05/3838905434',
|
||||
'<a href="http://flickr.com/photos/34807140@N05/3838905434" title="http://flickr.com/photos/34807140@N05/3838905434" class="attachment thumbnail" id="attachment-XXX" rel="nofollow external">flickr.com/photos/34807140@N05/3838905434</a>',
|
||||
'bare_domains'),
|
||||
array('What about parens (e.g. example.com/path/foo/(bar))?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>)?',
|
||||
'bare_domains'),
|
||||
array('What about parens (e.g. example.com/path/foo/(bar)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>?',
|
||||
'bare_domains'),
|
||||
array('What about parens (e.g. example.com/path/foo/(bar).)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/foo/(bar)" title="http://example.com/path/foo/(bar)" rel="nofollow external">example.com/path/foo/(bar)</a>.?',
|
||||
'bare_domains'),
|
||||
array('What about parens (e.g. example.com/path/(foo,bar)?',
|
||||
'What about parens (e.g. <a href="http://example.com/path/(foo,bar)" title="http://example.com/path/(foo,bar)" rel="nofollow external">example.com/path/(foo,bar)</a>?',
|
||||
'bare_domains'),
|
||||
array('example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
|
||||
'bare_domains'),
|
||||
array('example.org',
|
||||
'<a href="http://example.org/" title="http://example.org/" rel="nofollow external">example.org</a>',
|
||||
'bare_domains'),
|
||||
array('example.co.uk',
|
||||
'<a href="http://example.co.uk/" title="http://example.co.uk/" rel="nofollow external">example.co.uk</a>',
|
||||
'bare_domains'),
|
||||
array('www.example.co.uk',
|
||||
'<a href="http://www.example.co.uk/" title="http://www.example.co.uk/" rel="nofollow external">www.example.co.uk</a>',
|
||||
'bare_domains'),
|
||||
array('farm1.images.example.co.uk',
|
||||
'<a href="http://farm1.images.example.co.uk/" title="http://farm1.images.example.co.uk/" rel="nofollow external">farm1.images.example.co.uk</a>',
|
||||
'bare_domains'),
|
||||
array('example.museum',
|
||||
'<a href="http://example.museum/" title="http://example.museum/" rel="nofollow external">example.museum</a>',
|
||||
'bare_domains'),
|
||||
array('example.travel',
|
||||
'<a href="http://example.travel/" title="http://example.travel/" rel="nofollow external">example.travel</a>',
|
||||
'bare_domains'),
|
||||
array('example.com.',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.',
|
||||
'bare_domains'),
|
||||
array('example.com?',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>?',
|
||||
'bare_domains'),
|
||||
array('example.com!',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>!',
|
||||
'bare_domains'),
|
||||
array('example.com,',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>,',
|
||||
'bare_domains'),
|
||||
array('example.com;',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>;',
|
||||
'bare_domains'),
|
||||
array('example.com:',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>:',
|
||||
'bare_domains'),
|
||||
array('\'example.com\'',
|
||||
'\'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>\'',
|
||||
'bare_domains'),
|
||||
array('"example.com"',
|
||||
'"<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>"',
|
||||
'bare_domains'),
|
||||
array('example.com',
|
||||
'<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>',
|
||||
'bare_domains'),
|
||||
array('(example.com)',
|
||||
'(<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>)',
|
||||
'bare_domains'),
|
||||
array('[example.com]',
|
||||
'[<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>]',
|
||||
'bare_domains'),
|
||||
array('<example.com>',
|
||||
'<<a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>>',
|
||||
'bare_domains'),
|
||||
array('Hey, check out my cool site example.com okay?',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a> okay?',
|
||||
'bare_domains'),
|
||||
array('Hey, check out my cool site example.com.I made it.',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.I made it.',
|
||||
'bare_domains'),
|
||||
array('Hey, check out my cool site example.com.Funny thing...',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.Funny thing...',
|
||||
'bare_domains'),
|
||||
array('Hey, check out my cool site example.com.You will love it.',
|
||||
'Hey, check out my cool site <a href="http://example.com/" title="http://example.com/" rel="nofollow external">example.com</a>.You will love it.',
|
||||
'bare_domains'),
|
||||
array('example.com:8080/test.php',
|
||||
'<a href="http://example.com:8080/test.php" title="http://example.com:8080/test.php" rel="nofollow external">example.com:8080/test.php</a>',
|
||||
'bare_domains'),
|
||||
array('user_name+other@example.com',
|
||||
'<a href="mailto:user_name+other@example.com" title="mailto:user_name+other@example.com" rel="nofollow external">user_name+other@example.com</a>',
|
||||
'bare_domains'),
|
||||
array('user@example.com',
|
||||
'<a href="mailto:user@example.com" title="mailto:user@example.com" rel="nofollow external">user@example.com</a>',
|
||||
'bare_domains'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
print "This script must be run from the command line\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||
define('GNUSOCIAL', true);
|
||||
define('STATUSNET', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
class UUIDTest extends PHPUnit_Framework_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");
|
||||
}
|
||||
}
|
||||
|