]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
add test for removeWww Twig Extension 1461/head
authorNicolas Lœuillet <nicolas.loeuillet@smile.fr>
Tue, 6 Oct 2015 04:34:11 +0000 (06:34 +0200)
committerNicolas Lœuillet <nicolas.loeuillet@smile.fr>
Tue, 6 Oct 2015 07:09:26 +0000 (09:09 +0200)
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php [new file with mode: 0644]

index f58d0399bbe3a70a63e395e9f5c9f8f51635b3c4..b3f4709802e715af651853ab9c7aa4d60a12661a 100644 (file)
@@ -1,12 +1,12 @@
 {% extends "WallabagCoreBundle::layout.html.twig" %}
 
-{% block title %}{{ entry.title|raw }} ({{ entry.domainName }}){% endblock %}
+{% block title %}{{ entry.title|raw }} ({{ entry.domainName|removeWww }}){% endblock %}
 
 {% block content %}
     <div id="article_toolbar">
         <ul class="links">
             <li class="topPosF"><a href="#top" title="{% trans %}Back to top{% endtrans %}" class="tool top icon icon-arrow-up-thick"><span>{% trans %}Back to top{% endtrans %}</span></a></li>
-            <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.domainName }}</span></a></li>
+            <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.domainName|removeWww }}</span></a></li>
             <li><a title="{% trans %}Mark as read{% endtrans %}" class="tool icon icon-check {% if entry.isArchived == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
             <li><a title="{% trans %}Favorite{% endtrans %}" class="tool icon icon-star {% if entry.isStarred == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle favorite{% endtrans %}</span></a></li>
             <li><a title="{% trans %}Delete{% endtrans %}" class="tool delete icon icon-trash" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{% trans %}Delete{% endtrans %}</span></a></li>
index d3cef895e4c4703f50557409273afb927d7e7aa6..896b5376011d9c997d50e17520e24529f0ab1b2e 100644 (file)
@@ -1,6 +1,6 @@
 {% extends "WallabagCoreBundle::layout.html.twig" %}
 
-{% block title %}{{ entry.title|raw }} ({{ entry.domainName }}){% endblock %}
+{% block title %}{{ entry.title|raw }} ({{ entry.domainName|removeWww }}){% endblock %}
 
 {% block menu %}
     <div class="progress">
@@ -144,7 +144,7 @@ main {
             <h1>{{ entry.title|raw }} <a href="{{ path('edit', { 'id': entry.id }) }}" title="{% trans %}Edit title{% endtrans %}">✎</a></h1>
         </header>
         <aside>
-            <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link mdi-content-link"> <span>{{ entry.domainName }}</span></a>
+            <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link mdi-content-link"> <span>{{ entry.domainName|removeWww }}</span></a>
             <div id="list">
                 {% for tag in entry.tags %}<span><a href="#">{{ tag.label }}</a></span>{% endfor %}
             </div>
diff --git a/src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php b/src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php
new file mode 100644 (file)
index 0000000..4945e9a
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+namespace Wallabag\CoreBundle\Tests\Twig;
+
+use Wallabag\CoreBundle\Twig\WallabagExtension;
+
+class WallabagExtensionTest extends \PHPUnit_Framework_TestCase
+{
+    public function testRemoveWww()
+    {
+        $extension = new WallabagExtension();
+
+        $this->assertEquals("lemonde.fr", $extension->removeWww('www.lemonde.fr'));
+        $this->assertEquals("lemonde.fr", $extension->removeWww('lemonde.fr'));
+        $this->assertEquals("gist.github.com", $extension->removeWww('gist.github.com'));
+    }
+}