1
0
Fork 0
MySQLDumper/tests/unit/library/Msd/LogTest.php
2011-06-10 21:55:32 +00:00

71 Zeilen
Kein EOL
2,4 KiB
PHP

<?php
/**
* @group Log
*/
class Msd_LogTest extends PHPUnit_Framework_TestCase
{
public function testCanGetLogger()
{
$logger = new Msd_Log();
$this->assertInstanceof('Msd_Log', $logger);
}
public function testCanGetFilePathOfLoggerType()
{
$logger = new Msd_Log();
$this->assertInstanceof('Msd_Log', $logger);
$logPath = $logger->getFile(Msd_Log::PHP);
$this->assertEquals(WORK_PATH . '/log/php.log', $logPath);
$logPath = $logger->getFile(Msd_Log::PERL);
$this->assertEquals(WORK_PATH . '/log/perl.log', $logPath);
$logPath = $logger->getFile(Msd_Log::PERL_COMPLETE);
$this->assertEquals(WORK_PATH . '/log/perlComplete.log', $logPath);
$logPath = $logger->getFile(Msd_Log::ERROR);
$this->assertEquals(WORK_PATH . '/log/phpError.log', $logPath);
}
public function testCanGetLoggerOfGivenType()
{
$logger = new Msd_Log();
$this->assertInstanceof('Msd_Log', $logger);
$loggerTypes = array(
Msd_Log::PHP => WORK_PATH . '/log/php.log',
Msd_Log::PERL => WORK_PATH . '/log/perl.log',
Msd_Log::PERL_COMPLETE => WORK_PATH . '/log/perlComplete.log',
Msd_Log::ERROR => WORK_PATH . '/log/phpError.log',
);
foreach ($loggerTypes as $logType => $logPath) {
$this->assertInstanceof('Zend_Log', $logger->getLogInstance($logType));
$this->assertEquals($logger->getFile($logType), $logPath);
}
}
public function testClosesFileHandlesOnDestroy()
{
$logger = new Msd_Log();
$this->assertInstanceof('Msd_Log', $logger);
$loggerTypes = array(
Msd_Log::PHP => WORK_PATH . '/log/php.log',
Msd_Log::PERL => WORK_PATH . '/log/perl.log',
Msd_Log::PERL_COMPLETE => WORK_PATH . '/log/perlComplete.log',
Msd_Log::ERROR => WORK_PATH . '/log/phpError.log',
);
foreach ($loggerTypes as $logType => $logPath) {
$this->assertInstanceof('Zend_Log', $logger->getLogInstance($logType));
$this->assertEquals($logger->getFile($logType), $logPath);
}
unset($logger);
}
public function testCanWriteToLogFile()
{
$res = Msd_Log::write(Msd_Log::PHP, 'test message');
print_r($res);
}
}