xmpphp/tests/XMPPHP/LogTest.php
fritzy 1a3c6cf010 * fixed tests
git-svn-id: svn://netflint.net/xmpphp@68 ef36c318-a008-4979-b6e8-6b496270793b
2008-11-26 10:20:47 +00:00

163 lines
3.7 KiB
PHP
Executable File

<?php
require_once dirname(dirname(dirname(__FILE__))) . '/XMPPHP/Log.php';
class XMPPHP_LogTest extends PHPUnit_Framework_TestCase
{
public function testPrintoutNoOutput()
{
$log = new XMPPHP_Log();
$msg = 'I am a test log message';
ob_start();
$log->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);
}
}