This repository was archived by the owner on Sep 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Uri \WhatWg ;
6+
7+ use PHPUnit \Framework \Attributes \Test ;
8+ use PHPUnit \Framework \TestCase ;
9+
10+ final class UrlTest extends TestCase
11+ {
12+ #[Test]
13+ public function it_will_fail_parse_an_invalid_url (): void
14+ {
15+ $ errors = [];
16+ $ url = Url::parse ("invalid url " , null , $ errors );
17+
18+ self ::assertNull ($ url );
19+ self ::assertNotEmpty ($ errors );
20+ self ::assertInstanceOf (UrlValidationError::class, $ errors [0 ]);
21+ self ::assertSame (UrlValidationErrorType::MissingSchemeNonRelativeUrl, $ errors [0 ]->type );
22+ }
23+
24+ #[Test]
25+ public function it_will_return_soft_errors_when_uri_is_parsed_with_errors (): void
26+ {
27+ $ softErrors = [];
28+ $ url = new Url (" https://example.org " , null , $ softErrors );
29+
30+ self ::assertSame ('https://example.org/ ' , $ url ->toAsciiString ());
31+ self ::assertNotEmpty ($ softErrors );
32+ self ::assertInstanceOf (UrlValidationError::class, $ softErrors [0 ]);
33+ self ::assertSame (UrlValidationErrorType::InvalidUrlUnit, $ softErrors [0 ]->type );
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments