Move URL into separate file, handle source URL validation for sending webmentions
This commit is contained in:
1 parent
fca08de828
commit
ec83d67bde
8 files changed
+125
-60
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
use Lewisdale\Webmentions\Url;
|
||||
use PHPUnit\Framework\Attributes\TestWith;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UrlTest extends TestCase
|
||||
{
|
||||
|
||||
#[TestWith(["https://lewisdale.dev/post/a-post", "lewisdale.dev", true])]
|
||||
#[TestWith(["https://css-tricks.com/test/host", "lewisdale.dev", false])]
|
||||
#[TestWith(["ht:/lewisdale.dev/not-a-valid-url", "lewisdale.dev", false])]
|
||||
public function testItValidatesAHost(string $source, string $target, bool $expected)
|
||||
{
|
||||
$this->assertEquals($expected, Url::matchesHost($source, $target, $expected));
|
||||
}
|
||||
|
||||
#[TestWith(["http://a-valid-http-url.com", true])]
|
||||
#[TestWith(["ht://an-invalid-url.com", false])]
|
||||
#[TestWith(["https://no-tld./", false])]
|
||||
#[TestWith(["https://a-valid-https.com", true])]
|
||||
#[TestWith(["ftp://wrong-protocol.com", false])]
|
||||
public function testItValidatesAUrl(string $url, bool $expected)
|
||||
{
|
||||
$this->assertEquals($expected, Url::validateUrl($url));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user