aboutsummaryrefslogtreecommitdiff
path: root/engine/tests/api
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2012-12-06 14:02:18 -0500
committerBrett Profitt <brett.profitt@gmail.com>2012-12-06 14:02:18 -0500
commita60a58a6e884af4ab89b118bf2f23132335381fe (patch)
tree3e27ff18d2a6c476b526cc214263c51186ca75ad /engine/tests/api
parent6676577386c72d4a024c5c61a948589db8aaf9c7 (diff)
parent3bf72994688ad9292bf37444d80ab5ab1a002748 (diff)
downloadelgg-a60a58a6e884af4ab89b118bf2f23132335381fe.tar.gz
elgg-a60a58a6e884af4ab89b118bf2f23132335381fe.tar.bz2
Merge branch 'pr-420' into 1.8
Diffstat (limited to 'engine/tests/api')
-rw-r--r--engine/tests/api/output.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/engine/tests/api/output.php b/engine/tests/api/output.php
new file mode 100644
index 000000000..eb1a66b29
--- /dev/null
+++ b/engine/tests/api/output.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Test case for ElggAutop functionality.
+ * @author Steve Clay <steve@mrclay.org>
+ */
+class ElggCoreOutputAutoPTest extends ElggCoreUnitTest {
+
+ /**
+ * @var ElggAutop
+ */
+ protected $_autop;
+
+ public function setUp() {
+ $this->_autop = new ElggAutop();
+ }
+
+ public function testDomRoundtrip()
+ {
+ $d = dir(dirname(__DIR__) . '/test_files/output/autop');
+ $in = file_get_contents($d->path . "/domdoc_in.html");
+ $exp = file_get_contents($d->path . "/domdoc_exp.html");
+
+ $doc = new DOMDocument();
+ libxml_use_internal_errors(true);
+ $doc->loadHTML("<html><meta http-equiv='content-type' content='text/html; charset=utf-8'><body>"
+ . $in . '</body></html>');
+ $serialized = $doc->saveHTML();
+ list(,$out) = explode('<body>', $serialized, 2);
+ list($out) = explode('</body>', $out, 2);
+
+ $this->assertEqual($exp, $out, "DOMDocument's parsing/serialization roundtrip");
+ }
+
+ public function testProcess()
+ {
+ $data = $this->provider();
+ foreach ($data as $row) {
+ list($test, $in, $exp) = $row;
+ $out = $this->_autop->process($in);
+ $this->assertEqual($exp, $out, "Equality case {$test}");
+ }
+ }
+
+ public function provider()
+ {
+ $d = dir(dirname(__DIR__) . '/test_files/output/autop');
+ $tests = array();
+ while (false !== ($entry = $d->read())) {
+ if (preg_match('/^([a-z\\-]+)\.in\.html$/i', $entry, $m)) {
+ $tests[] = $m[1];
+ }
+ }
+
+ $data = array();
+ foreach ($tests as $test) {
+ $data[] = array(
+ $test,
+ file_get_contents($d->path . '/' . "{$test}.in.html"),
+ file_get_contents($d->path . '/' . "{$test}.exp.html"),
+ );
+ }
+ return $data;
+ }
+}