ext/uri: Reorganises legacy tests - #23286
Conversation
There was a problem hiding this comment.
Two options for these: keep grouped in eg parsing with zend_ prefix or give dedicated zend dir. Thoughts?
There was a problem hiding this comment.
I'm fine with putting it into the general directory with something like internal_api_success_parse_url_parsing.php or similar. The important thing here is that the internal API is used by the zend_test function.
There was a problem hiding this comment.
Moved them to ext/uri/tests/zend and kept your proposed prefix. Only having the suffix does not make it clear what it is; having a zend directory convention in extensions helps contributors that are new to the code base. Ok with it?
74844f2 to
d2bfb5c
Compare
kocsismate
left a comment
There was a problem hiding this comment.
partial review yet, I'll continue later
There was a problem hiding this comment.
much of these cases are already covered, please check them (e.g. there is ext/uri/tests/rfc3986/parsing/path_success_relative_reference.phpt and ext/uri/tests/rfc3986/parsing/path_success_relative_reference_absolute.phpt). so probably only mailto:johndoe@example.com and maybe /// is needed (but let's separate them for better readability)
To avoid miscommunication: I plan to address everything in one go when you continued. In case your second pass didn't yield anything new please update me so I know it's done and we do not wait for each other. :) |
| @@ -1,5 +1,5 @@ | |||
| --TEST-- | |||
| Test reference resolution | |||
| Test Uri\Rfc3986\Uri reference resolution during parsing | |||
There was a problem hiding this comment.
the usual format should be used
There was a problem hiding this comment.
not sure what you mean
There was a problem hiding this comment.
this is not needed, since it doesn't have a baseUrl
There was a problem hiding this comment.
the rest of the cases should go into separate tests, and the assertion should be the usual one
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
There was a problem hiding this comment.
Done. Split to:
parse_success_absolute_with_base.phpt
parse_success_relative_with_base.phpt
parse_success_without_base.phpt
Normalise case was removed in accordance with your comment below.
There was a problem hiding this comment.
I'm not really sure a separate case for normalized URI is needed here, unless it improves coverage somehow 🤔 (but I don't think it does)
There was a problem hiding this comment.
Removed. It did not. As mentioned above, these were just 1:1: moved. Goal here was to retain coverage, nothing was added extra.
|
|
||
| $uri = new Uri\Rfc3986\Uri('https://example.com'); | ||
| try { | ||
| $uri->__unserialize([['uri' => 'ftp://example.org'], []]); |
There was a problem hiding this comment.
this can be a serialization test indeed
There was a problem hiding this comment.
It already is an serialisation test?
I went through all rfc3986 tests now. There are quite a few recurring problems which even apply to the WHATWG URL tests, so please resolve my comments globally, and then I'll continue with another, full review round. |
d2bfb5c to
43b5f64
Compare
Aside: before your review I treated the task as mechanical moves and extractions. So the pre-review state was 1:1 to before this PR ; I didn't check for duplications. I get now what you want. Thing is, I am not exactly confident to decide what qualifies as identical, what differs enough to keep it asserted, and what justifies a removal. I also cannot check each move against all 448 tests, my brain will explode. 😅 I did check the cases you mentioned (+whatwg) -- but if the goal really is to have zero duplicates, I cannot claim that's achieved now. |
kocsismate
left a comment
There was a problem hiding this comment.
Sorry, it's a very long list of review comments, only a few files are left, but I have to take a break now. Feel free to address my comments already.
| $uri1 = Uri\Rfc3986\Uri::parse("https://example.com"); | ||
| $uri2 = $uri1->withHost("t%3As%2Ft.com"); | ||
|
|
||
| var_dump($uri1->getRawHost()); |
There was a problem hiding this comment.
The existing tests only assert the modified component of the original URI like this:
var_dump($uri1->getRawHost());
var_dump($uri2->getRawHost());
var_dump($uri2->toRawString());
var_dump($uri2->getHost());
var_dump($uri2->toString());
| var_dump($uri1->toRawString()); | ||
|
|
||
| var_dump($uri2->getPort()); | ||
| var_dump($uri2->toRawString()); |
There was a problem hiding this comment.
The estabilished format:
| var_dump($uri1->toRawString()); | |
| var_dump($uri2->getPort()); | |
| var_dump($uri2->toRawString()); | |
| var_dump($uri1->getPort()); | |
| var_dump($uri2->getPort()); | |
| var_dump($uri2->toRawString()); |
| var_dump($uri1->getPort()); | ||
| var_dump($uri1->toString()); | ||
|
|
||
| var_dump($uri2->getPort()); | ||
| var_dump($uri2->toString()); |
There was a problem hiding this comment.
| var_dump($uri1->getPort()); | |
| var_dump($uri1->toString()); | |
| var_dump($uri2->getPort()); | |
| var_dump($uri2->toString()); | |
| var_dump($uri1->getPort()); | |
| var_dump($uri2->getPort()); | |
| var_dump($uri2->toRawString()); |
There was a problem hiding this comment.
maybe it is rather a general test?
| $url = Uri\WhatWg\Url::parse("file:///E:\Documents and Settings"); | ||
|
|
||
| var_dump($url); | ||
| var_dump($url->toUnicodeString()); |
There was a problem hiding this comment.
| var_dump($url->toUnicodeString()); |
| $url = new Uri\WhatWg\Url("https://example.com/foo/bar%2Fbaz"); | ||
|
|
||
| var_dump($url); | ||
| var_dump($url->toUnicodeString()); |
There was a problem hiding this comment.
| var_dump($url->toUnicodeString()); |
| var_dump($url); | ||
| var_dump($url->toUnicodeString()); | ||
| var_dump($url->toAsciiString()); | ||
| var_dump($url->getPath()); |
There was a problem hiding this comment.
| var_dump($url->getPath()); |
Sorry if I got you into more than what you subscribed for. :) If you are still patient then we are not that far away from the finish line. I wanted to avoid keeping bad/unnecessary tests from the legacy folder, that's why I did such a "strict" review. I hope that you understand it :) |
Nah,that's all good. Really just wanted to let you know that I will have to rely on your deeper knowledge of the domain. Will pick up on the comments soon! :) |
Co-authored-by: Máté Kocsis <kocsismate90@gmail.com>
c2f6384 to
72c11be
Compare
| } catch (Throwable $e) { | ||
| echo $e::class, ": ", $e->getMessage(), PHP_EOL; | ||
| echo $e::class, ': ', $e->getMessage(), "\n"; | ||
| var_dump($e->errors[0]->type === Uri\WhatWg\UrlValidationErrorType::PortOutOfRange); |
There was a problem hiding this comment.
Added this because the other test has it too.
| <?php | ||
|
|
||
| $errors = []; | ||
| $url = Uri\WhatWg\Url::parse("🐘", null, $errors); |
There was a problem hiding this comment.
Not exactly the same as the one with emoji in host.
|
Should be done @kocsismate.
Notes:
Failure unrelated. |
Ref: #23271 (review) @kocsismate
Depends on: #23271 (
ready here, but marked as draft until 23271 is merged)Coverage