Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@piwik.org>2017-12-13 23:49:21 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2017-12-13 23:49:21 +0300
commit56f7bc5a879e868436c4286cb4cfb6983d12bf54 (patch)
tree6ea24ff036561415ee66c6f1985afc02503a9bf3 /tests/PHPUnit
parentf91f646c2f5df8d4432aa86db2a2f4a3d9a50452 (diff)
Improves truncate twig filter (#12347)
* respect encoded entities in truncate filter * adds some simple tests
Diffstat (limited to 'tests/PHPUnit')
-rw-r--r--tests/PHPUnit/Unit/TwigTest.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/TwigTest.php b/tests/PHPUnit/Unit/TwigTest.php
new file mode 100644
index 0000000000..85fce40bf0
--- /dev/null
+++ b/tests/PHPUnit/Unit/TwigTest.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Tests\Unit;
+
+require_once(PIWIK_INCLUDE_PATH . '/core/Twig.php');
+
+/**
+ * @group Twig
+ */
+class TwigTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @dataProvider getTruncateTests
+ */
+ public function testPiwikFilterTruncate($in, $size, $out)
+ {
+ $truncated = \Piwik\piwik_filter_truncate($in, $size);
+ $this->assertEquals($out, $truncated);
+ }
+
+ public function getTruncateTests()
+ {
+ return [
+ ['abc', 4, 'abc'],
+ ['abc&quot;', 4, 'abc&quot;'],
+ ['abc&nbsp;', 4, 'abc&nbsp;'],
+ ['abcdef', 3, 'abc...'],
+ ['ab&amp;ef', 3, 'ab&amp;...'],
+ ['some&#9660;thing', 5, 'some&#9660;...'],
+ ['ab&ef ;', 3, 'ab&...'],
+ ['&lt;&gt;&#9660;&nbsp;', 4, '&lt;&gt;&#9660;&nbsp;']
+ ];
+ }
+} \ No newline at end of file