2015-01-27 13:25:20 +01:00
|
|
|
<?php
|
2015-06-08 16:47:14 +02:00
|
|
|
|
2015-06-08 17:09:25 +02:00
|
|
|
/*
|
2023-02-17 05:13:51 +01:00
|
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
|
|
* SPDX-License-Identifier: MIT
|
2015-06-08 17:09:25 +02:00
|
|
|
*/
|
|
|
|
|
2017-11-19 19:01:31 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2015-01-27 13:25:20 +01:00
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
|
2024-01-28 01:46:21 +01:00
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
use PHPUnit\Framework\Attributes\Group;
|
2018-06-11 17:54:59 +02:00
|
|
|
use Respect\Validation\Test\RuleTestCase;
|
2017-11-04 11:21:40 +01:00
|
|
|
|
2024-01-28 01:46:21 +01:00
|
|
|
#[Group('rule')]
|
|
|
|
#[CoversClass(Url::class)]
|
2018-06-11 17:54:59 +02:00
|
|
|
final class UrlTest extends RuleTestCase
|
2015-01-27 13:25:20 +01:00
|
|
|
{
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{Url, mixed}> */
|
|
|
|
public static function providerForValidInput(): iterable
|
2015-01-27 13:25:20 +01:00
|
|
|
{
|
2018-06-11 17:54:59 +02:00
|
|
|
$rule = new Url();
|
2015-01-27 13:25:20 +01:00
|
|
|
|
2018-06-11 17:54:59 +02:00
|
|
|
return [
|
|
|
|
[$rule, 'ftp://ftp.is.co.za.example.org/rfc/rfc1808.txt'],
|
|
|
|
[$rule, 'gopher://spinaltap.micro.umn.example.edu/00/Weather/California/Los%20Angeles'],
|
|
|
|
[$rule, 'http://www.ietf.org/rfc/rfc2396.txt'],
|
|
|
|
[$rule, 'http://www.math.uio.no.example.net/faq/compression-faq/part1.html'],
|
|
|
|
[$rule, 'https://www.youtube.com/watch?v=6FOUqQt3Kg0'],
|
|
|
|
[$rule, 'ldap://[2001:db8::7]/c=GB?objectClass?one'],
|
|
|
|
[$rule, 'mailto:John.Doe@example.com'],
|
|
|
|
[$rule, 'mailto:mduerst@ifi.unizh.example.gov'],
|
|
|
|
[$rule, 'news:comp.infosystems.www.servers.unix'],
|
|
|
|
[$rule, 'news:comp.infosystems.www.servers.unix'],
|
|
|
|
[$rule, 'telnet://192.0.2.16:80/'],
|
|
|
|
[$rule, 'telnet://melvyl.ucop.example.edu/'],
|
|
|
|
];
|
2015-01-27 13:25:20 +01:00
|
|
|
}
|
|
|
|
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{Url, mixed}> */
|
|
|
|
public static function providerForInvalidInput(): iterable
|
2015-01-27 13:25:20 +01:00
|
|
|
{
|
2018-06-11 17:54:59 +02:00
|
|
|
$rule = new Url();
|
2015-01-27 13:25:20 +01:00
|
|
|
|
2015-10-18 03:44:47 +02:00
|
|
|
return [
|
2018-06-11 17:54:59 +02:00
|
|
|
[$rule, 'example.com'],
|
|
|
|
[$rule, 'http:/example.com/'],
|
|
|
|
[$rule, 'tel:+1-816-555-1212'],
|
|
|
|
[$rule, 'urn:oasis:names:specification:docbook:dtd:xml:4.1.2'],
|
2015-10-18 03:44:47 +02:00
|
|
|
];
|
2015-01-27 13:25:20 +01:00
|
|
|
}
|
|
|
|
}
|