summaryrefslogtreecommitdiff
path: root/tests/Framework/Text2Html.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-05-17 09:27:17 +0200
committerAleksander Machniak <alec@alec.pl>2014-05-17 09:27:17 +0200
commitefc470f0ac7587707665e92701e3937c9b6cc78d (patch)
tree6674f2f57526f086e02755142f46901db74469c5 /tests/Framework/Text2Html.php
parentf1aaca6807742f7a890db152395d5c293b6e4e66 (diff)
parentc0a5aa5f5ff38ac7b8a650b07c134b7b86deb27f (diff)
Merge branch 'dev-text2html'
Conflicts: program/js/app.js Fix handling magic_quotes in rcube_text2html and rcube_html2text - move stripslashes from these classes to action files
Diffstat (limited to 'tests/Framework/Text2Html.php')
-rw-r--r--tests/Framework/Text2Html.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/tests/Framework/Text2Html.php b/tests/Framework/Text2Html.php
new file mode 100644
index 000000000..8d091d5c9
--- /dev/null
+++ b/tests/Framework/Text2Html.php
@@ -0,0 +1,93 @@
+<?php
+
+/**
+ * Test class to test rcube_text2html class
+ *
+ * @package Tests
+ */
+class Framework_Text2Html extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Data for test_text2html()
+ */
+ function data_text2html()
+ {
+ $options = array(
+ 'begin' => '',
+ 'end' => '',
+ 'break' => '<br>',
+ 'links' => false,
+ 'flowed' => false,
+ 'wrap' => false,
+ 'space' => '_', // replace UTF-8 non-breaking space for simpler testing
+ );
+
+ $data[] = array(" aaaa", "_aaaa", $options);
+ $data[] = array("aaaa aaaa", "aaaa_aaaa", $options);
+ $data[] = array("aaaa aaaa", "aaaa__aaaa", $options);
+ $data[] = array("aaaa aaaa", "aaaa___aaaa", $options);
+ $data[] = array("aaaa\taaaa", "aaaa____aaaa", $options);
+ $data[] = array("aaaa\naaaa", "aaaa<br>aaaa", $options);
+ $data[] = array("aaaa\n aaaa", "aaaa<br>_aaaa", $options);
+ $data[] = array("aaaa\n aaaa", "aaaa<br>__aaaa", $options);
+ $data[] = array("aaaa\n aaaa", "aaaa<br>___aaaa", $options);
+ $data[] = array("\taaaa", "____aaaa", $options);
+ $data[] = array("\naaaa", "<br>aaaa", $options);
+ $data[] = array("\n aaaa", "<br>_aaaa", $options);
+ $data[] = array("\n aaaa", "<br>__aaaa", $options);
+ $data[] = array("\n aaaa", "<br>___aaaa", $options);
+ $data[] = array("aaaa\n\nbbbb", "aaaa<br><br>bbbb", $options);
+ $data[] = array(">aaaa \n>aaaa", "<blockquote>aaaa_<br>aaaa</blockquote>", $options);
+ $data[] = array(">aaaa\n>aaaa", "<blockquote>aaaa<br>aaaa</blockquote>", $options);
+ $data[] = array(">aaaa \n>bbbb\ncccc dddd", "<blockquote>aaaa_<br>bbbb</blockquote>cccc_dddd", $options);
+ $data[] = array("aaaa-bbbb/cccc", "aaaa-&#8288;bbbb/&#8288;cccc", $options);
+
+ $options['flowed'] = true;
+
+ $data[] = array(" aaaa", "aaaa", $options);
+ $data[] = array("aaaa aaaa", "aaaa_aaaa", $options);
+ $data[] = array("aaaa aaaa", "aaaa__aaaa", $options);
+ $data[] = array("aaaa aaaa", "aaaa___aaaa", $options);
+ $data[] = array("aaaa\taaaa", "aaaa____aaaa", $options);
+ $data[] = array("aaaa\naaaa", "aaaa<br>aaaa", $options);
+ $data[] = array("aaaa\n aaaa", "aaaa<br>aaaa", $options);
+ $data[] = array("aaaa\n aaaa", "aaaa<br>_aaaa", $options);
+ $data[] = array("aaaa\n aaaa", "aaaa<br>__aaaa", $options);
+ $data[] = array("\taaaa", "____aaaa", $options);
+ $data[] = array("\naaaa", "<br>aaaa", $options);
+ $data[] = array("\n aaaa", "<br>aaaa", $options);
+ $data[] = array("\n aaaa", "<br>_aaaa", $options);
+ $data[] = array("\n aaaa", "<br>__aaaa", $options);
+ $data[] = array("aaaa\n\nbbbb", "aaaa<br><br>bbbb", $options);
+ $data[] = array(">aaaa \n>aaaa", "<blockquote>aaaa aaaa</blockquote>", $options);
+ $data[] = array(">aaaa\n>aaaa", "<blockquote>aaaa<br>aaaa</blockquote>", $options);
+ $data[] = array(">aaaa \n>bbbb\ncccc dddd", "<blockquote>aaaa bbbb</blockquote>cccc_dddd", $options);
+
+ $options['flowed'] = false;
+ $options['wrap'] = true;
+
+ $data[] = array(">>aaaa bbbb\n>>\n>>>\n>cccc\n\ndddd eeee",
+ "<blockquote><blockquote>aaaa bbbb<br><br><blockquote><br></blockquote></blockquote>cccc</blockquote><br>dddd eeee", $options);
+ $data[] = array("\n>>aaaa\n\ndddd",
+ "<br><blockquote><blockquote>aaaa</blockquote></blockquote><br>dddd", $options);
+ $data[] = array("aaaa\n>bbbb\n>cccc\n\ndddd\n>>test",
+ "aaaa<blockquote>bbbb<br>cccc</blockquote><br>dddd<blockquote><blockquote>test</blockquote></blockquote>", $options);
+
+ return $data;
+ }
+
+ /**
+ * Test text to html conversion
+ *
+ * @dataProvider data_text2html
+ */
+ function test_text2html($input, $output, $options)
+ {
+ $t2h = new rcube_text2html($input, false, $options);
+
+ $html = $t2h->get_html();
+
+ $this->assertEquals($output, $html);
+ }
+}