Verified Commit c42d65e4 authored by Dave Long's avatar Dave Long
Browse files

Issue #3219923 by andypost, Amber Himes Matz, jhodgdon: Add tests to enforce...

Issue #3219923 by andypost, Amber Himes Matz, jhodgdon: Add tests to enforce correct use of help_topic_link and help_route_link functions
parent 61c851c3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
---
label: 'URL test topic that uses outdated url function'
top_level: true
---
{% set link_uses_url_func = render_var(url('valid.route')) %}
<p>{% trans %}This topic should be top-level. It is used to test URLs{% endtrans %}</p>
<ul>
  <li>{% trans %}Valid link, but generated with <code>url()</code> instead of <code>help_route_link()</code> or <code>help_topic_link()</code>: {{ link_uses_url_func }}{% endtrans %}</li>
</ul>
+7 −0
Original line number Diff line number Diff line
@@ -179,6 +179,9 @@ protected function verifyTopic($id, $definitions, $response = 200) {
    // HTML tags, there is nothing left (that is, all text is translated).
    $text = preg_replace('|\s+|', '', $this->renderHelpTopic($template_text, 'remove_translated'));
    $this->assertEmpty($text, 'Topic ' . $id . ' Twig file has all of its text translated');

    // Verify that the Twig url() function was not used.
    $this->assertStringNotContainsString('url(', $template, 'Topic ' . $id . ' appears to use the url() function. Replace with help_topic_link() or help_topic_route(). See https://drupal.org/node/3074421');
  }

  /**
@@ -275,6 +278,10 @@ protected function verifyBadTopic($id, $definitions) {
          $this->assertStringContainsString('has the correct H2-H6 heading hierarchy', $message);
          break;

        case 'url_func_used':
          $this->assertStringContainsString('appears to use the url() function', $message);
          break;

        default:
          // This was an unexpected error.
          throw $e;