diff --git a/tests/AllTests.php b/tests/AllTests.php
new file mode 100755
index 0000000..049325f
--- /dev/null
+++ b/tests/AllTests.php
@@ -0,0 +1,31 @@
+addTestSuite('XMPPHP_LogTest');
+ $suite->addTestSuite('XMPPHP_XMLObjTest');
+ $suite->addTestSuite('XMPPHP_XMPPTest');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'AllTests::main') {
+ AllTests::main();
+}
diff --git a/tests/XMPPHP/LogTest.php b/tests/XMPPHP/LogTest.php
new file mode 100755
index 0000000..9c1a236
--- /dev/null
+++ b/tests/XMPPHP/LogTest.php
@@ -0,0 +1,162 @@
+log('test');
+ $result = ob_get_clean();
+
+ $this->assertEquals('', $result);
+ }
+
+ public function testPrintoutOutput()
+ {
+ $log = new XMPPHP_Log(true);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg);
+ $result = ob_get_clean();
+
+ $this->assertContains($msg, $result);
+ }
+
+ public function testPrintoutNoOutputWithDefaultLevel()
+ {
+ $log = new XMPPHP_Log(true, XMPPHP_Log::LEVEL_ERROR);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg);
+ $result = ob_get_clean();
+
+ $this->assertSame('', $result);
+ }
+
+ public function testPrintoutOutputWithDefaultLevel()
+ {
+ $log = new XMPPHP_Log(true, XMPPHP_Log::LEVEL_INFO);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg);
+ $result = ob_get_clean();
+
+ $this->assertContains($msg, $result);
+ }
+
+ public function testPrintoutNoOutputWithCustomLevel()
+ {
+ $log = new XMPPHP_Log(true, XMPPHP_Log::LEVEL_INFO);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg, XMPPHP_Log::LEVEL_DEBUG);
+ $result = ob_get_clean();
+
+ $this->assertSame('', $result);
+ }
+
+ public function testPrintoutOutputWithCustomLevel()
+ {
+ $log = new XMPPHP_Log(true, XMPPHP_Log::LEVEL_INFO);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg, XMPPHP_Log::LEVEL_INFO);
+ $result = ob_get_clean();
+
+ $this->assertContains($msg, $result);
+ }
+
+ public function testExplicitPrintout()
+ {
+ $log = new XMPPHP_Log(false);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg);
+ $result = ob_get_clean();
+
+ $this->assertSame('', $result);
+ }
+
+ public function testExplicitPrintoutResult()
+ {
+ $log = new XMPPHP_Log(false);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg);
+ $result = ob_get_clean();
+
+ $this->assertSame('', $result);
+
+ ob_start();
+ $log->printout();
+ $result = ob_get_clean();
+
+ $this->assertContains($msg, $result);
+ }
+
+ public function testExplicitPrintoutClear()
+ {
+ $log = new XMPPHP_Log(false);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg);
+ $result = ob_get_clean();
+
+ $this->assertSame('', $result);
+
+ ob_start();
+ $log->printout();
+ $result = ob_get_clean();
+
+ $this->assertContains($msg, $result);
+
+ ob_start();
+ $log->printout();
+ $result = ob_get_clean();
+
+ $this->assertSame('', $result);
+ }
+
+ public function testExplicitPrintoutLevel()
+ {
+ $log = new XMPPHP_Log(false, XMPPHP_Log::LEVEL_ERROR);
+
+ $msg = 'I am a test log message';
+
+ ob_start();
+ $log->log($msg);
+ $result = ob_get_clean();
+
+ $this->assertSame('', $result);
+
+ ob_start();
+ $log->printout(true, XMPPHP_Log::LEVEL_INFO);
+ $result = ob_get_clean();
+
+ $this->assertSame('', $result);
+ }
+
+
+}
diff --git a/tests/XMPPHP/XMLObjTest.php b/tests/XMPPHP/XMLObjTest.php
new file mode 100755
index 0000000..bb6fb41
--- /dev/null
+++ b/tests/XMPPHP/XMLObjTest.php
@@ -0,0 +1,53 @@
+";
+
+ $result = $xmlobj->toString();
+
+ $this->assertSame($expected, $result);
+ }
+
+ public function testToStringNameNamespaceAttr()
+ {
+ $xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace', array('attr1'=>'valA', 'attr2'=>'valB'));
+
+ $expected = "";
+
+ $result = $xmlobj->toString();
+
+ $this->assertSame($expected, $result);
+ }
+
+ public function testToStringNameNamespaceData()
+ {
+ $xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace', array(), 'I am test data');
+
+ $expected = "I am test data";
+
+ $result = $xmlobj->toString();
+
+ $this->assertSame($expected, $result);
+ }
+
+ public function testToStringNameNamespaceSub()
+ {
+ $xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace');
+ $sub1 = new XMPPHP_XMLObj('subName', 'subNameSpace');
+ $xmlobj->subs = array($sub1);
+
+ $expected = "";
+
+ $result = $xmlobj->toString();
+
+ $this->assertSame($expected, $result);
+ }
+
+}
diff --git a/tests/XMPPHP/XMPPTest.php b/tests/XMPPHP/XMPPTest.php
new file mode 100755
index 0000000..ec21225
--- /dev/null
+++ b/tests/XMPPHP/XMPPTest.php
@@ -0,0 +1,44 @@
+useEncryption(false);
+ $xmpp->connect(10);
+ $xmpp->processUntil('session_start');
+ $xmpp->presence();
+ $xmpp->message('stephan@jabber.wentz.it', 'This is a test message!');
+ $xmpp->disconnect();
+ } catch(XMPPHP_Exception $e) {
+ return;
+ } catch(Exception $e) {
+ $this->fail('Unexpected Exception thrown: '.$e->getMessage());
+ }
+
+ $this->fail('Expected XMPPHP_Exception not thrown!');
+ }
+
+ public function testAuthException()
+ {
+ try {
+ $xmpp = new XMPPHP_XMPP('jabber.wentz.it', 5222, 'invalidusername', 'invalidpassword', 'xmpphp', 'jabber.wentz.it', true, XMPPHP_Log::LEVEL_VERBOSE);
+ $xmpp->useEncryption(false);
+ $xmpp->connect(10);
+ $xmpp->processUntil('session_start');
+ $xmpp->presence();
+ $xmpp->message('stephan@jabber.wentz.it', 'This is a test message!');
+ $xmpp->disconnect();
+ } catch(XMPPHP_Exception $e) {
+ return;
+ } catch(Exception $e) {
+ $this->fail('Unexpected Exception thrown: '.$e->getMessage());
+ }
+
+ $this->fail('Expected XMPPHP_Exception not thrown!');
+ }
+}