2021-03-24 06:27:51 +13:00
|
|
|
<?php
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2021-03-24 06:27:51 +13:00
|
|
|
/**
|
|
|
|
* Utopia PHP Framework
|
|
|
|
*
|
|
|
|
* @package Framework
|
|
|
|
* @subpackage Tests
|
|
|
|
*
|
|
|
|
* @link https://github.com/utopia-php/framework
|
|
|
|
* @author Appwrite Team <team@appwrite.io>
|
|
|
|
* @version 1.0 RC4
|
|
|
|
* @license The MIT License (MIT) <http://www.opensource.org/licenses/mit-license.php>
|
|
|
|
*/
|
|
|
|
|
2022-08-01 22:22:04 +12:00
|
|
|
namespace Tests\Unit\Network\Validators;
|
2021-03-24 06:27:51 +13:00
|
|
|
|
2022-08-01 22:22:04 +12:00
|
|
|
use Appwrite\Network\Validator\Host;
|
2021-03-24 06:27:51 +13:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class HostTest extends TestCase
|
|
|
|
{
|
2022-08-01 22:22:04 +12:00
|
|
|
protected ?Host $host = null;
|
2021-03-24 06:27:51 +13:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
public function setUp(): void
|
2021-03-24 06:27:51 +13:00
|
|
|
{
|
|
|
|
$this->host = new Host(['appwrite.io', 'subdomain.appwrite.test', 'localhost']);
|
|
|
|
}
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
public function tearDown(): void
|
2021-03-24 06:27:51 +13:00
|
|
|
{
|
|
|
|
$this->host = null;
|
|
|
|
}
|
|
|
|
|
2022-08-01 22:22:04 +12:00
|
|
|
public function testIsValid(): void
|
2021-03-24 06:27:51 +13:00
|
|
|
{
|
|
|
|
// Assertions
|
|
|
|
$this->assertEquals($this->host->isValid('https://appwrite.io/link'), true);
|
|
|
|
$this->assertEquals($this->host->isValid('https://localhost'), true);
|
|
|
|
$this->assertEquals($this->host->isValid('localhost'), false);
|
|
|
|
$this->assertEquals($this->host->isValid('http://subdomain.appwrite.test/path'), true);
|
|
|
|
$this->assertEquals($this->host->isValid('http://test.subdomain.appwrite.test/path'), false);
|
|
|
|
$this->assertEquals($this->host->getType(), 'string');
|
|
|
|
}
|
|
|
|
}
|