3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * Main database structure configuration file.
22 * Here are described all the tables, fields and indexes Friendica needs to work.
23 * The entry order is mostly alphabetic - with the exception of tables that are used in foreign keys.
25 * Syntax (braces indicate optionale values):
27 * "comment" => "Description of the table",
30 * "type" => "<field type>{(<field size>)} <unsigned>",
32 * {"extra" => "auto_increment",}
33 * {"default" => "<default value>",}
34 * {"default" => NULL_DATE,} (for datetime fields)
36 * {"foreign|relation" => ["<foreign key table name>" => "<foreign key field name>"],}
37 * "comment" => "Description of the fields"
42 * "PRIMARY" => ["<primary key field name>", ...],
43 * "<index name>" => [{"UNIQUE",} "<field name>{(<key size>)}", ...]
48 * Whenever possible prefer "foreign" before "relation" with the foreign keys.
49 * "foreign" adds true foreign keys on the database level, while "relation" is just an indicator of a table relation without any consequences
51 * If you need to make any change, make sure to increment the DB_UPDATE_VERSION constant value below.
55 namespace Friendica\Test\src\Protocol;
57 use Friendica\Protocol\WebFingerUri;
58 use PHPUnit\Framework\TestCase;
60 class WebFingerUriTest extends TestCase
62 public function dataFromString(): array
66 'expectedLong' => 'acct:selma@www.example.com:8080/friend',
67 'expectedShort' => 'selma@www.example.com:8080/friend',
68 'input' => 'acct:selma@www.example.com:8080/friend',
71 'expectedLong' => 'acct:selma@www.example.com:8080/friend',
72 'expectedShort' => 'selma@www.example.com:8080/friend',
73 'input' => 'selma@www.example.com:8080/friend',
76 'expectedLong' => 'acct:bob@example.com',
77 'expectedShort' => 'bob@example.com',
78 'input' => 'bob@example.com',
81 'expectedLong' => 'acct:alice@example.acct:90',
82 'expectedShort' => 'alice@example.acct:90',
83 'input' => 'alice@example.acct:90',
89 * @dataProvider dataFromString
90 * @param string $expectedLong
91 * @param string $expectedShort
92 * @param string $input
95 public function testFromString(string $expectedLong, string $expectedShort, string $input)
97 $uri = WebFingerUri::fromString($input);
99 $this->assertEquals($expectedLong, $uri->getLongForm());
100 $this->assertEquals($expectedShort, $uri->getShortForm());
103 public function dataFromStringFailure()
107 'input' => 'example.com',
109 'missing user @' => [
110 'input' => '@example.com',
115 'missing host @' => [
118 'missing everything' => [
125 * @dataProvider dataFromStringFailure
126 * @param string $input
129 public function testFromStringFailure(string $input)
131 $this->expectException(\InvalidArgumentException::class);
133 WebFingerUri::fromString($input);