Added test

This commit is contained in:
Michael 2023-12-05 05:51:39 +00:00
parent 7b1b3fe8cf
commit be2e715eb1
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Test\src\Util;
use Friendica\Util\Network;
use PHPUnit\Framework\TestCase;
/**
* Network utility test class
*/
class NetworkTest extends TestCase
{
public function testValidUri()
{
self::assertTrue(Network::isValidUri('https://friendi.ca'));
self::assertTrue(Network::isValidUri('magnet:?xs=https%3A%2F%2Ftube.jeena.net%2Flazy-static%2Ftorrents%2F04bec7a8-34de-4847-b080-6ee00c4b3d49-1080-hls.torrent&xt=urn:btih:5def5a24dfa7307e999a0d4f0fcc29c3e2b13be2&dn=My+fediverse+setup+-+I+host+everything+myself&tr=https%3A%2F%2Ftube.jeena.net%2Ftracker%2Fannounce&tr=wss%3A%2F%2Ftube.jeena.net%3A443%2Ftracker%2Fsocket&ws=https%3A%2F%2Ftube.jeena.net%2Fstatic%2Fstreaming-playlists%2Fhls%2F23989f41-e230-4dbf-9111-936bc730bf50%2Fe5905de3-e488-4bb8-a1e8-eb7a53ac24ad-1080-fragmented.mp4'));
self::assertTrue('did:plc:geqiabvo4b4jnfv2paplzcge');
self::assertFalse(Network::isValidUri('https://'));
self::assertFalse(Network::isValidUri(''));
self::assertFalse(Network::isValidUri(null));
self::assertFalse(Network::isValidUri('friendi.ca'));
}
}