Problem/Motivation

A <a href="/"></a> link is not displayed correctly. It is replaced with but only works with fromRoute(), not fromUri(), so that needs a special case somewhere.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mbovan’s picture

Status: Active » Needs review
FileSize
1.2 KB

Providing a fix.

Berdir’s picture

Status: Needs review » Needs work
+++ b/src/Tests/PathologicTest.php
@@ -141,7 +141,7 @@ class PathologicTest extends WebTestBase {
         check_markup('<a href="/"></a>', $format_id),
-        '<a href="' . $paths['/'] . '"></a>',
+        '<a href="' . str_replace('%3Cfront%3E', '', $paths['/']) . '"></a>',
         t('Path with just slash. Clean URLs: !clean; protocol style: !ps', $t10ns)

I don't really get what this is doing :)

Can we have a test-fail patch?

mbovan’s picture

Status: Needs work » Needs review
FileSize
555 bytes

Here is the test-only patch.

Re #2: $paths['/'] contains something like: "http//d8.dev/"... To assert results correctly I replaced <front> (encoded as %3Cfront%3E) with empty string.

Status: Needs review » Needs work

The last submitted patch, 3: front_is_not-2538928-3-TEST-ONLY.patch, failed testing.

mbovan’s picture

Status: Needs work » Needs review
FileSize
1.22 KB
954 bytes

As discussed, changed test method that returns $path, instead of changing $path output in assertEqual() .

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

I guess that check could be outside of the if but yes, I like this a lot more. Before, we were testing for the broken behavior because both places did it incorrectly.

Garrett Albright’s picture

Weird. Tests don't fail before this patch… it looks like the output of the test case was wrong in the same way that Pathologic was wrong. Not really sure what to make of that.

Anyway, committed and pushed.

Garrett Albright’s picture

Version: 8.x-1.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Needs review

Marking for NR on the D7 branch so we can see if it's having the same problem. I don't think it does, though.

Berdir’s picture

Version: 7.x-3.x-dev » 8.x-1.x-dev
Status: Needs review » Fixed

Yes, 7.x-1.x is certainly fine, this is completely different in 8.x, moving back to 8.x :) And yes, that's the problem with dynamic assertions, when the test is implementing the same logic as the actual code then you aren't testing much :)

Not easy to change that for URL's, only thing I can see is having hardcoded Url::fromRoute('') and so on objects that you are comparing against, that might be a bit clearer than a helper function that does magic.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.