1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
<?php
declare(strict_types = 1);
namespace Embed\Tests;
use function Embed\isHttp;
use PHPUnit\Framework\TestCase;
class FunctionsTest extends TestCase
{
public function urlsProvider(): array
{
return [
['https://foo.com', true],
['http://foo.com', true],
['mailto:foo@example.com', false],
['tel:+1234567890', false],
['data:foo', false],
['./foo', true],
['/foo', true],
['../foo', true],
['foo.com', true],
['//foo.com', true],
];
}
/**
* @dataProvider urlsProvider
*/
public function testIsHttp(string $url, bool $expected)
{
$result = isHttp($url);
$this->assertSame($expected, $result);
}
}
|