From 06dbabffb1d0cbae2a707968b2cd34a996d23171 Mon Sep 17 00:00:00 2001
From: David Flatz
Date: Wed, 3 Feb 2016 18:12:16 +0100
Subject: make tests compatible to php 5.3 std

---
 tests/exec.t    |  2 +-
 tests/it_dbi.t  |  8 ++++----
 tests/it_html.t | 24 ++++++++++++------------
 tests/it_mail.t | 26 +++++++++++++-------------
 tests/it_pipe.t | 19 ++++++++++++++-----
 tests/it_xml.t  |  2 +-
 tests/itjs.t    |  2 +-
 7 files changed, 46 insertions(+), 37 deletions(-)

diff --git a/tests/exec.t b/tests/exec.t
index da5113d..c155c88 100755
--- a/tests/exec.t
+++ b/tests/exec.t
@@ -84,7 +84,7 @@ it::system('touch /tmp/it_system_test');
 ok(file_exists('/tmp/it_system_test'), 'shell command gets executed');
 
 @unlink('/tmp/it_system_test');
-it::system('touch {path}', 'path' => '/tmp/it_system_test');
+it::system('touch {path}', array('path' => '/tmp/it_system_test'));
 ok(file_exists('/tmp/it_system_test'), 'shell command with argument');
 
 @unlink('/tmp/it_system_test');
diff --git a/tests/it_dbi.t b/tests/it_dbi.t
index c9e7d9d..ca39f1f 100755
--- a/tests/it_dbi.t
+++ b/tests/it_dbi.t
@@ -140,13 +140,13 @@ is(
 is(
 	$record->update(array('x' => 18), array('x' => 17)),
 	1,
-	"return affected rows",
+	"return affected rows"
 );
 
 is(
 	$record->update(array('x' => 18), array('x' => 17)),
 	0,
-	"return zero affected rows",
+	"return zero affected rows"
 );
 
 $record->update(array('-x' => 'POW(2,2) * 10'));
@@ -166,14 +166,14 @@ is (
 
 $record->update(array('foo' => NULL));
 is (
-	$record->_set('foo' => ""),
+	$record->_set(array('foo' => "")),
 	"SET `foo`=''",
 	'update: _set optimization with NULL => ""'
 );
 $record->update(array('foo' => "bar"));
 $record->update(array('foo' => ""));
 is (
-	$record->_set('foo' => NULL),
+	$record->_set(array('foo' => NULL)),
 	"SET `foo`=NULL",
 	'update: _set optimization with "" => NULL'
 );
diff --git a/tests/it_html.t b/tests/it_html.t
index 4c06d9d..4f4da24 100755
--- a/tests/it_html.t
+++ b/tests/it_html.t
@@ -52,40 +52,40 @@ is(
 );
 
 is(
-	div('arg' => "val: \x03, \x0e, \x0f, \x0c, \xc2\x80, \xc2\x9f, \x09, \n", "\x02, \x0e, \x0f, \x0c, \xc2\x80, \xc2\x9f, \x09, \n"),
+	div(array('arg' => "val: \x03, \x0e, \x0f, \x0c, \xc2\x80, \xc2\x9f, \x09, \n", "\x02, \x0e, \x0f, \x0c, \xc2\x80, \xc2\x9f, \x09, \n")),
 	"<div arg=\"val:  ,  ,  ,  ,  ,  , \x09, &#10;\">\x02, \x0e, \x0f, \x0c, \xc2\x80, \xc2\x9f, \x09, \n</div>\n",
 	"blank unprintable characters and illegal utf8 in attributes but not in normal text"
 );
 
 is(
-	div("arg\x03\x0e\x0f\xc2\x80\xc2\x9fendarg" => "value", "content"),
+	div(array("arg\x03\x0e\x0f\xc2\x80\xc2\x9fendarg" => "value", "content")),
 	"<div arg\x03\x0e\x0f\xc2\x80\xc2\x9fendarg=\"value\">content</div>\n",
 	"don't blank unprintable characters and illegal utf8 in attribute names"
 );
 
 is(
-	div('arg' => "abc äüö éá© œàè îôÇ xyz", "abc äüö éá© œàè îôÇ xyz"),
+	div(array('arg' => "abc äüö éá© œàè îôÇ xyz", "abc äüö éá© œàè îôÇ xyz")),
 	"<div arg=\"abc äüö éá© œàè îôÇ xyz\">abc äüö éá© œàè îôÇ xyz</div>\n",
-	"leave legal utf8 intact",
+	"leave legal utf8 intact"
 );
 
 unset($GLOBALS['debug_utf8check']);
 is(
-	div('arg' => "value \xc2", "content"),
+	div(array('arg' => "value \xc2", "content")),
 	"<div arg=\"value \xc2\">content</div>\n",
-	"handle single \\xc2 at end of attribute value",
+	"handle single \\xc2 at end of attribute value"
 );
 
 is(
-	div("arg\x00end" => "value \x00 end", "content \x00 content end"),
+	div(array("arg\x00end" => "value \x00 end", "content \x00 content end")),
 	"<div arg\x00end=\"value   end\">content \x00 content end</div>\n",
-	"handle 0-bytes",
+	"handle 0-bytes"
 );
 
 is(
-	div('arg' => "& \" < > \n '", "& \" < > \n '"),
+	div(array('arg' => "& \" < > \n '", "& \" < > \n '")),
 	"<div arg=\"&amp; &quot; &lt; &gt; &#10; '\">& \" < > \n '</div>\n",
-	"use html entities in attributes but not in normal text",
+	"use html entities in attributes but not in normal text"
 );
 
 # Test different html types
@@ -93,7 +93,7 @@ foreach (array('html5' => "<br flag>", 'html' => "<br flag>", 'xhtml' => "<br fl
 {
 	unset($GLOBALS['it_html']);
 	new it_html(array('htmltype' => $type));
-	is (trim(br('flag' => true)), $value, "Check empty tag and attribute for $type");
+	is (trim(br(array('flag' => true))), $value, "Check empty tag and attribute for $type");
 }
 
 # XML generation
@@ -180,7 +180,7 @@ is(
 is(
 	it_html::sanitize('<div></div>'), 
 	'',
-	'empty tags removal',
+	'empty tags removal'
 );
 
 is(
diff --git a/tests/it_mail.t b/tests/it_mail.t
index 44ed30d..687480c 100755
--- a/tests/it_mail.t
+++ b/tests/it_mail.t
@@ -9,19 +9,19 @@ $mail = new it_mail();
 is(
 	$mail->addrlist_escape('éxample@example.com', true),
 	'éxample@example.com',
-	"Don't escape plain email addresses in email headers",
+	"Don't escape plain email addresses in email headers"
 );
 
 is(
 	$mail->header_escape('éxample@example.com'),
 	'=?utf-8?Q?=C3=A9xample@example.com?=',
-	"Escape plain email in non-email headers",
+	"Escape plain email in non-email headers"
 );
 
 is(
 	$mail->addrlist_escape('Èxample User <èxample@example.com>', true),
 	'=?utf-8?Q?=C3=88xample_User?= <èxample@example.com>',
-	"Escape name but not email in email headers",
+	"Escape name but not email in email headers"
 );
 
 is(
@@ -33,50 +33,50 @@ is(
 is(
 	$mail->addrlist_escape('example@example.com, éxample@example.com, Sömeone Ëlse <sömeone@example.com>', true),
 	'example@example.com, éxample@example.com,=?utf-8?Q?S=C3=B6meone_=C3=8Blse?= <sömeone@example.com>',
-	"Don't escape email addresses but escape realnames",
+	"Don't escape email addresses but escape realnames"
 );
 
 is(
 	$mail->addrlist_escape('"Alfred E. Neuman" <neuman@example.com>', true),
 	'"Alfred E. Neuman" <neuman@example.com>',
-	"Don't remove quoting characters from realname",
+	"Don't remove quoting characters from realname"
 );
 
 
-$mail = new it_mail(
+$mail = new it_mail(array(
 	'From' => 'Someone Ïmportant <ïmportant@search.ch>',
 	'To' => 'éxample@example.com, example@example.com, Sömeone Ëlse <sömeone@example.com>, "Alfred E. Neuman" <neuman@example.com>, "Schmitt, Sören" <schmitt@example.com>',
 	'Cc' => 'éxample@example.com, example@example.com, Sömeone Ëlse <sömeone@example.com>, "Alfred E. Neuman" <neuman@example.com>, "Schmitt, Sören" <schmitt@example.com>',
 	'Bcc' => 'éxample@example.com, example@example.com, Sömeone Ëlse <sömeone@example.com>, "Alfred E. Neuman" <neuman@example.com>, "Schmitt, Sören" <schmitt@example.com>',
-	'Subject' => "§önÐë®z€ı¢ħèṇ",
-);
+	'Subject' => "§önÐë®z€ı¢ħèṇ"
+));
 
 is(
 	$mail->to[0],
 	'éxample@example.com, example@example.com,=?utf-8?Q?S=C3=B6meone_=C3=8Blse?= <sömeone@example.com>, "Alfred E. Neuman" <neuman@example.com>,=?utf-8?Q?Schmitt,_S=C3=B6ren?= <schmitt@example.com>',
-	'Escape To: field as addrlist',
+	'Escape To: field as addrlist'
 );
 
 is(
 	$mail->cc[0],
 	'éxample@example.com, example@example.com,=?utf-8?Q?S=C3=B6meone_=C3=8Blse?= <sömeone@example.com>, "Alfred E. Neuman" <neuman@example.com>,=?utf-8?Q?Schmitt,_S=C3=B6ren?= <schmitt@example.com>',
-	'Escape Cc: field as addrlist',
+	'Escape Cc: field as addrlist'
 );
 
 is(
 	$mail->bcc[0],
 	'éxample@example.com, example@example.com,=?utf-8?Q?S=C3=B6meone_=C3=8Blse?= <sömeone@example.com>, "Alfred E. Neuman" <neuman@example.com>,=?utf-8?Q?Schmitt,_S=C3=B6ren?= <schmitt@example.com>',
-	'Escape Bcc: field as addrlist',
+	'Escape Bcc: field as addrlist'
 );
 
 is(
 	$mail->header_values[0],
 	'=?utf-8?Q?Someone_=C3=8Fmportant?= <ïmportant@search.ch>',
-	'Escape From: field as addrlist',
+	'Escape From: field as addrlist'
 );
 
 is(
 	$mail->subject,
 	"§önÐë®z€ı¢ħèṇ",
-	"Don't escape Subject: field on instanziation",
+	"Don't escape Subject: field on instanziation"
 );
diff --git a/tests/it_pipe.t b/tests/it_pipe.t
index ce55469..56ee672 100755
--- a/tests/it_pipe.t
+++ b/tests/it_pipe.t
@@ -2,8 +2,17 @@
 <?php
 
 # csv()
-is(json_encode((new it_pipe('data' => array("a\tb", "1\t2")))->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");
-is(json_encode((new it_pipe('data' => array("a;b",   "1;2")))->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");
-is(json_encode((new it_pipe('data' => array("a,b",   "1,2")))->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");
-is(json_encode((new it_pipe('data' => array("a\tb", "1\t2")))->csv("c,d")), '[{"c":"1","d":"2"}]',           "it_pipe::csv()");
-is(json_encode((new it_pipe('data' => array("\t", "1\t2")))->csv()),        '[{"field0":"1","field1":"2"}]', "it_pipe::csv()");
+$pipe = new it_pipe(array('data' => array("a\tb", "1\t2")));
+is(json_encode($pipe->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");
+
+$pipe = new it_pipe(array('data' => array("a;b",   "1;2")));
+is(json_encode($pipe->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");
+
+$pipe = new it_pipe(array('data' => array("a,b",   "1,2")));
+is(json_encode($pipe->csv()),      '[{"a":"1","b":"2"}]',           "it_pipe::csv()");
+
+$pipe = new it_pipe(array('data' => array("a\tb", "1\t2")));
+is(json_encode($pipe->csv("c,d")), '[{"c":"1","d":"2"}]',           "it_pipe::csv()");
+
+$pipe = new it_pipe(array('data' => array("\t", "1\t2")));
+is(json_encode($pipe->csv()),        '[{"field0":"1","field1":"2"}]', "it_pipe::csv()");
diff --git a/tests/it_xml.t b/tests/it_xml.t
index d74fadf..f53ceeb 100755
--- a/tests/it_xml.t
+++ b/tests/it_xml.t
@@ -72,7 +72,7 @@ match(
 match(
 	'<foo>&amp;amp; &lt;a&gt; &#38;amp; &#60;b&#62; &#x26;amp; &#x3C;c&#x3E; &uuml;</foo>',
 	'foo Object ( [val] => &amp; <a> &amp; <b> &amp; <c> ü ) ',
-	'Predecode illegal entities while keeping properly encoded ones',
+	'Predecode illegal entities while keeping properly encoded ones'
 );
 
 match(
diff --git a/tests/itjs.t b/tests/itjs.t
index 4fcc9b4..8dff992 100755
--- a/tests/itjs.t
+++ b/tests/itjs.t
@@ -50,5 +50,5 @@ is(
 is(
 	itjs::serialize(array("foo'foo" => "bar")),
 	"{'foo\'foo':\"bar\"}",
-	"quote ' in keys",
+	"quote ' in keys"
 );
-- 
cgit v1.2.3