|
4123 - in trunk/EventLog: src src/interfaces src/mapper src/structs src/wri: msg#00296web.ezcomponents.cvs
Author: Alexandru Stanoi Date: 2006-11-29 09:24:18 +0100 (Wed, 29 Nov 2006) New Revision: 4123 Log: - Added some more tests. - Added __isset() method where it was missing. - Added missing file comments, @ignore, @access private. Modified: trunk/EventLog/src/context.php trunk/EventLog/src/interfaces/writer.php trunk/EventLog/src/log.php trunk/EventLog/src/log_message.php trunk/EventLog/src/mapper/filter_rule.php trunk/EventLog/src/mapper/filterset.php trunk/EventLog/src/structs/log_filter.php trunk/EventLog/src/writers/writer_file.php trunk/EventLog/src/writers/writer_unix_file.php trunk/EventLog/tests/context_test.php trunk/EventLog/tests/log_message_test.php trunk/EventLog/tests/log_test.php trunk/EventLog/tests/mapper/filterset_test.php trunk/EventLog/tests/suite.php trunk/EventLog/tests/writers/writer_file_test.php trunk/EventLog/tests/writers/writer_unix_file_test.php Modified: trunk/EventLog/src/context.php =================================================================== --- trunk/EventLog/src/context.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/context.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -18,7 +18,6 @@ */ class ezcLogContext { - /** * Stores the contexts for the severities. * @@ -33,11 +32,8 @@ */ protected $sourceMap; - /** * Resets this object to its initial state by removing all context mappings. - * - * @return void */ public function reset() { @@ -57,7 +53,6 @@ * Bitmask that specifies all the event types that share the given * context. * @param array(string=>string) $context - * @return void */ public function setSeverityContext( $severityMask, $context ) { @@ -86,7 +81,6 @@ * their context. * * @param int $severityMask - * @return void */ public function unsetSeverityContext( $severityMask ) { @@ -114,7 +108,6 @@ * @param array(string=>string) $context * Specifies the keys and values that should be stored into this * context object. - * @return void */ public function setSourceContext( array $eventSources, $context ) { @@ -133,7 +126,6 @@ * Remove the contexts for the given $eventSources. * * @param array(string) $eventSources - * @return void */ public function unsetSourceContext( array $eventSources ) { @@ -148,12 +140,11 @@ * * If there is no context available this method will return an empty array. * - * * @param int $eventType The integer that specifies the event type. * The range of this integer is 2^(N+): * ( 1, 2, 4, 8, ... ) * @param string $eventSource - * @return array + * @return array(string=>string) */ public function getContext( $eventType, $eventSource ) { @@ -162,6 +153,5 @@ return array_merge( $a, $b ); // return array_merge( (array) $this->severityMap[$eventType], (array) $this->sourceMap[$eventSource] ); } - } ?> Modified: trunk/EventLog/src/interfaces/writer.php =================================================================== --- trunk/EventLog/src/interfaces/writer.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/interfaces/writer.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -29,7 +29,8 @@ * The array $optional contains extra information that can be added to the log. For example: * line numbers, file names, usernames, etc. * - * @throws ezcLogWriterException when the log writer was unable to write the log message. + * @throws ezcLogWriterException + * If the log writer was unable to write the log message * * @param string $message * @param int $severity @@ -38,7 +39,6 @@ * $param string $source * @param string $category * @param array(string=>string) $optional - * @return void */ public function writeLogMessage( $message, $severity, $source, $category, $optional = array() ); } Modified: trunk/EventLog/src/log.php =================================================================== --- trunk/EventLog/src/log.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/log.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -247,10 +247,11 @@ /** * Sets the property $name to $value. * - * @throws ezcBasePropertyNotFoundException if the property does not exist. + * @throws ezcBasePropertyNotFoundException + * If the property $name does not exist * @param string $name * @param mixed $value - * @return void + * @ignore */ public function __set( $name, $value ) { @@ -265,12 +266,14 @@ throw new ezcBasePropertyNotFoundException( $name ); } - /** + /** * Returns the property $name. * - * @throws ezcBasePropertyNotFoundException if the property does not exist. + * @throws ezcBasePropertyNotFoundException + * If the property $name does not exist * @param string $name * @return mixed + * @ignore */ public function __get( $name ) { @@ -285,12 +288,30 @@ } /** + * Returns true if the property $name is set, otherwise false. + * + * @param string $name + * @return bool + * @ignore + */ + public function __isset( $name ) + { + switch ( $name ) + { + case 'source': + case 'category': + return isset( $this->properties[$name] ); + + default: + return false; + } + } + + /** * Resets the log instance to its initial state. * * All sourceAttributes, severityAttributes, and writers will be removed. * The default source and category are also reset. - * - * @return void */ public function reset() { @@ -307,7 +328,6 @@ * ezcLogMapper can be replaced with this method. * * @param ezcLogMapper $mapper - * @return void */ public function setMapper( ezcLogMapper $mapper ) { @@ -326,8 +346,6 @@ /** * Sets the source and category defaults to "default". - * - * @return void */ protected function setDefaults() { @@ -344,7 +362,6 @@ * the log file. For these setups you can disable writer exceptions. * * @param bool $enable - * @return void */ public function throwWriterExceptions( $enable ) { @@ -360,7 +377,7 @@ * - $severity: the severity of the log message. * - $attributes[ "source" ]: the source from where the log message comes. * - $attributes[ "category" ]: the category of the log message. - * + * * See for more information about filter matching the classes {@link ezcLog} and * {@link ezcLogFilter}. * @@ -382,7 +399,7 @@ * done by a user. * - FAILED_AUDIT: Informative logging about an action from a module * with a negative result. A failed login will most likely added to this severity. - * + * * The attributes array $attributes can have one or multiple attributes that will * be added to the log. If source and category are given, they will override the default * source or category given as property to this object. Further more it is up to the @@ -410,7 +427,6 @@ * @param int $severity One of the following severity constants: * DEBUG, SUCCES_AUDIT, FAIL_AUDIT, INFO, NOTICE, WARNING, ERROR, or FATAL. * @param array(string=>string) $attributes - * @return void */ public function log( $message, $severity, array $attributes = array() ) { @@ -459,7 +475,6 @@ * * @param integer $severityMask Multiple severities are specified with a logic-or. * @param array(string=>string) $attributes - * @return void */ public function setSeverityAttributes( $severityMask, $attributes ) { @@ -485,7 +500,6 @@ * * @param array(string) $sources * @param array(string => string) $attributes - * @return void */ public function setSourceAttributes ( $sources, $attributes ) { @@ -549,13 +563,12 @@ * * </code> * - * Notice that the ezcLog component is not loaded at all when the logging is disabled. + * Notice that the ezcLog component is not loaded at all when the logging is disabled. * * @param int $errno * @param int $erstr * @param string $errfile * @param int $errline - * @return void */ public static function logHandler( $errno, $errstr, $errfile, $errline ) { Modified: trunk/EventLog/src/log_message.php =================================================================== --- trunk/EventLog/src/log_message.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/log_message.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -48,81 +48,90 @@ * * @var array(string=>mixed) */ - protected $properties = array( "message" => "", "source" => "", "category" => "", "severity" => "" ); + protected $properties = array( "message" => "", "source" => "", "category" => "", "severity" => "" ); + /** + * Constructs the ezcLogMessage from the $message, $severity, $defaultSource and $defaultCategory. + * + * $message is parsed by parseMessage() and properties are set. + * + * @param string $message + * @param int $severity + * @param string $defaultSource Use this source when not given in the message itself. + * @param string $defaultCategory Use this category when not give in the message itself. + */ + public function __construct( $message, $severity, $defaultSource, $defaultCategory ) + { + $this->parseMessage( $message, $severity, $defaultSource, $defaultCategory ); + } /** * Sets the property $name to $value. * - * @throws ezcBasePropertyNotFoundException if the property does not exist. + * @throws ezcBasePropertyNotFoundException + * If the property $name does not exist * @param string $name * @param mixed $value - * @return void + * @ignore */ public function __set( $name, $value ) { switch ( $name ) { case 'message': - $this->properties['message'] = $value; - break; case 'source': - $this->properties['source'] = $value; - break; case 'category': - $this->properties['category'] = $value; - break; case 'severity': - $this->properties['severity'] = $value; - break; - - default: - throw new ezcBasePropertyNotFoundException( $name ); + $this->properties[$name] = $value; + return; } + throw new ezcBasePropertyNotFoundException( $name ); } /** * Returns the property $name. * - * @throws ezcBasePropertyNotFoundException if the property does not exist. + * @throws ezcBasePropertyNotFoundException + * If the property $name does not exist * @param string $name * @return mixed + * @ignore */ public function __get( $name ) { switch ( $name ) { case 'message': - return $this->properties['message']; - break; case 'source': - return $this->properties['source']; - break; case 'category': - return $this->properties['category']; - break; case 'severity': - return $this->properties['severity']; - break; + return $this->properties[$name]; } throw new ezcBasePropertyNotFoundException( $name ); } /** - * Constructs the ezcLogMessage from the $message, $severity, $defaultSource and $defaultCategory. + * Returns true if the property $name is set, otherwise false. * - * $message is parsed by parseMessage() and properties are set. - * - * @param string $message - * @param int $severity - * @param string $defaultSource Use this source when not given in the message itself. - * @param string $defaultCategory Use this category when not give in the message itself. + * @param string $name + * @return bool + * @ignore */ - public function __construct( $message, $severity, $defaultSource, $defaultCategory ) + public function __isset( $name ) { - $this->parseMessage( $message, $severity, $defaultSource, $defaultCategory ); + switch ( $name ) + { + case 'message': + case 'source': + case 'category': + case 'severity': + return isset( $this->properties[$name] ); + + default: + return false; + } } /** @@ -138,7 +147,6 @@ * @param int $severity * @param string $defaultSource * @param string $defaultCategory - * @return void */ public function parseMessage( $message, $severity, $defaultSource, $defaultCategory ) { Modified: trunk/EventLog/src/mapper/filter_rule.php =================================================================== --- trunk/EventLog/src/mapper/filter_rule.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/mapper/filter_rule.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -19,6 +19,7 @@ * * @package EventLog * @version //autogentag// + * @access private */ class ezcLogFilterRule { @@ -82,7 +83,6 @@ * @param ezcLogFilter $filter * @param mixed $container * @param bool $continueProcessing - * @return void */ public function __construct( ezcLogFilter $filter, $container, $continueProcessing ) { @@ -114,8 +114,6 @@ /** * Creates an internal structure, to quickly lookup the combination of severity, source, and * categories. - * - * @return void */ protected function createStructure() { @@ -210,7 +208,5 @@ return $result; } - } - ?> Modified: trunk/EventLog/src/mapper/filterset.php =================================================================== --- trunk/EventLog/src/mapper/filterset.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/mapper/filterset.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,6 +1,6 @@ <?php /** - * File containing the ezcLogMap class. + * File containing the ezcLogFilterSet class. * * @package EventLog * @version //autogentag// @@ -19,9 +19,10 @@ * Each rule determines whether the log message matches with the filter rule. If the * log message matches, it calls the writer and decide whether the filter set * stops processing. - * + * * @package EventLog * @version //autogentag// + * @access private */ class ezcLogFilterSet implements ezcLogMapper { @@ -40,10 +41,9 @@ private $cache = array(); /** - * Appends a rule to the end of the filter set. - * + * Appends a rule to the end of the filter set. + * * @param ezcLogFilter $filter - * @return void */ public function appendRule( $filter ) { @@ -52,10 +52,10 @@ } /** - * Deletes the the last rule from the filter set. + * Deletes the last rule from the filter set. * * Returns false if the filter set is empty, otherwise true. - * + * * @return bool */ public function deleteLastRule() @@ -69,7 +69,6 @@ return false; } - /** * Returns the variable assigned to the combination of a severity $severity, source $source, @@ -111,8 +110,6 @@ /** * Clears the cache. - * - * return void */ protected function clearCache() { Modified: trunk/EventLog/src/structs/log_filter.php =================================================================== --- trunk/EventLog/src/structs/log_filter.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/structs/log_filter.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,5 +1,4 @@ <?php - /** * File containing the ezcLogFilter class. * @@ -42,7 +41,6 @@ */ public $severity; - /** * The source of the log message. * @@ -61,7 +59,6 @@ */ public $category; - /** * Empty constructor */ @@ -72,7 +69,4 @@ $this->category = $category; } } - - - ?> Modified: trunk/EventLog/src/writers/writer_file.php =================================================================== --- trunk/EventLog/src/writers/writer_file.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/writers/writer_file.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -35,7 +35,7 @@ * // And call the parent class * $this->write( $type, $source, $category, $res ); * } - *} + * } * </code> * * @package EventLog @@ -51,7 +51,6 @@ */ protected $openFiles = array(); - /** * Keeps track of which group of messages should be stored * in what file. @@ -84,7 +83,6 @@ */ protected $maxFiles; - /** * Constructs an ezcLogFileWriter. * @@ -131,7 +129,6 @@ } } - /** * This method writes the $string to a file. * @@ -143,7 +140,6 @@ * @param string $eventSource * @param string $eventCategory * @param string $string - * @return void */ protected function write( $eventType, $eventSource, $eventCategory, $string ) { @@ -251,7 +247,6 @@ return false; } - /** * Maps the filename $fileName to the messages specified by the {@link ezcLogFilter} $logFilter. * @@ -259,7 +254,6 @@ * * @param ezcLogFilter $logFilter * @param string $fileName - * @return void */ public function setFile( ezcLogFilter $logFilter, $fileName ) { @@ -275,7 +269,6 @@ // * // * @param ezcLogFilter $logFilter // * @param string $fileName -// * @return void // */ // public function unmap( $logFilter, $fileName ) // { Modified: trunk/EventLog/src/writers/writer_unix_file.php =================================================================== --- trunk/EventLog/src/writers/writer_unix_file.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/src/writers/writer_unix_file.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,6 +1,6 @@ <?php /** - * File containing the ezcLogWriterUnix class. + * File containing the ezcLogUnixFileWriter class. * * @package EventLog * @version //autogentag// Modified: trunk/EventLog/tests/context_test.php =================================================================== --- trunk/EventLog/tests/context_test.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/tests/context_test.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,5 +1,17 @@ <?php +/** + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package EventLog + * @subpackage Tests + */ +/** + * @package EventLog + * @subpackage Tests + */ class ezcLogContextTest extends ezcTestCase { protected $context; Modified: trunk/EventLog/tests/log_message_test.php =================================================================== --- trunk/EventLog/tests/log_message_test.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/tests/log_message_test.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,5 +1,17 @@ <?php +/** + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package EventLog + * @subpackage Tests + */ +/** + * @package EventLog + * @subpackage Tests + */ class ezcLogMessageTest extends ezcTestCase { protected $tm; @@ -75,9 +87,43 @@ $msg = new ezcLogMessage($this->tm->getMessage(1, true, true), E_USER_NOTICE, false, false ); $this->assertEquals( ezcLog::NOTICE, $msg->severity ); } + + public function testProperties() + { + $msg = new ezcLogMessage( $this->tm->getMessage( 1, true, true ), E_USER_WARNING, false, false ); + try + { + $val = $msg->no_such_property; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBasePropertyNotFoundException $e ) + { + $this->assertEquals( "No such property name 'no_such_property'.", $e->getMessage() ); + } + try + { + $msg->no_such_property = "xxx"; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBasePropertyNotFoundException $e ) + { + $this->assertEquals( "No such property name 'no_such_property'.", $e->getMessage() ); + } + $msg = new ezcLogMessage( $this->tm->getMessage( 1, true, true ), false, false, false ); + $this->assertEquals( false, $msg->severity ); + } + + public function testIsSet() + { + $msg = new ezcLogMessage( $this->tm->getMessage( 1, true, true ), E_USER_WARNING, false, false ); + $this->assertEquals( true, isset( $msg->message ) ); + $this->assertEquals( true, isset( $msg->source ) ); + $this->assertEquals( true, isset( $msg->category ) ); + $this->assertEquals( true, isset( $msg->severity ) ); + $this->assertEquals( false, isset( $msg->no_such_property ) ); + } } - class TestMessages { /** Modified: trunk/EventLog/tests/log_test.php =================================================================== --- trunk/EventLog/tests/log_test.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/tests/log_test.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,5 +1,17 @@ <?php +/** + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package EventLog + * @subpackage Tests + */ +/** + * @package EventLog + * @subpackage Tests + */ class ezcLogTest extends ezcTestCase { protected $log; @@ -9,7 +21,7 @@ parent::__construct($string); // These instances yield for all these tests. - $this->log = ezcLog::getInstance(); + //$this->log = ezcLog::getInstance(); date_default_timezone_set("UTC"); } @@ -202,7 +214,8 @@ // public function testTriggerError() // { // $this->log->reset(); -// $this->log->map(new ezcLogFilter(), $writer = new ezcLogUnixFileWriter( $this->getTempDir(), "default.log" )); +// //$this->log->map(new ezcLogFilter(), $writer = new ezcLogUnixFileWriter( $this->getTempDir(), "default.log" )); +// $this->log->getMapper()->appendRule( new ezcLogFilterRule(new ezcLogFilter(), $a = new ezcLogUnixFileWriter( $this->getTempDir(), "default.log" ), true ) ); // trigger_error("Bernard, looking at all the quarters that fell out of the vending machine he broke with the crowbar.", E_USER_WARNING); // // $regExp = "|\[Warning\] \[default\] \[default\] Bern.* \(file: .*/log_test.php, line: \d+\)|"; @@ -351,7 +364,6 @@ { return; } - $this->fail("Expected an ezcLogWriterException."); } @@ -497,13 +509,64 @@ $this->assertRegExp("/service: Paynet Terminal/", $lines[2]); } + public function testOtherSeverities() + { + $dir = $this->getTempDir(); + $file = "default.log"; + $log = ezcLog::getInstance(); + $writer = new ezcLogUnixFileWriter( "$dir", "$file" ); + $log->getMapper()->appendRule( new ezcLogFilterRule( new ezcLogFilter, $writer, true ) ); + + $username = "John Doe"; + $service = "Paynet Terminal"; + // Add automatically the username to the log message, when the log message is FATAL. + $log->setSeverityAttributes( ezcLog::FATAL, array( "username" => $username ) ); + $log->log( "Hackers have breached the security!", ezcLog::FATAL, array( "source" => "security", "category" => "login" ) ); + $log->log( "Something unknown happened...", false, array( "source" => "security", "category" => "login" ) ); + + $lines = file( "$dir/$file" ); + $this->assertRegExp("/username: John Doe/", $lines[0]); + } + + public function testProperties() + { + $log = ezcLog::getInstance(); + $log->source = "Payment"; + $log->category = "Corporate"; + $this->assertEquals( "Payment", $log->source ); + $this->assertEquals( "Corporate", $log->category ); + try + { + $val = $log->no_such_property; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBasePropertyNotFoundException $e ) + { + $this->assertEquals( "No such property name 'no_such_property'.", $e->getMessage() ); + } + try + { + $log->no_such_property = "xxx";; + $this->fail( "Expected exception was not thrown" ); + } + catch ( ezcBasePropertyNotFoundException $e ) + { + $this->assertEquals( "No such property name 'no_such_property'.", $e->getMessage() ); + } + } + + public function testIsSet() + { + $log = ezcLog::getInstance(); + $this->assertEquals( true, isset( $log->source ) ); + $this->assertEquals( true, isset( $log->category ) ); + $this->assertEquals( false, isset( $log->no_such_property ) ); + } + public static function suite() { return new PHPUnit_Framework_TestSuite("ezcLogTest"); } } - - - ?> Modified: trunk/EventLog/tests/mapper/filterset_test.php =================================================================== --- trunk/EventLog/tests/mapper/filterset_test.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/tests/mapper/filterset_test.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,6 +1,17 @@ <?php +/** + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package EventLog + * @subpackage Tests + */ - +/** + * @package EventLog + * @subpackage Tests + */ class ezcLogFilterSetTest extends ezcTestCase { private $map; Modified: trunk/EventLog/tests/suite.php =================================================================== --- trunk/EventLog/tests/suite.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/tests/suite.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,11 +1,24 @@ <?php +/** + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package EventLog + * @subpackage Tests + */ + require_once( "log_test.php"); require_once( "log_message_test.php"); require_once( "mapper/filterset_test.php"); require_once( "context_test.php"); require_once( "writers/writer_file_test.php"); require_once( "writers/writer_unix_file_test.php"); - + +/** + * @package EventLog + * @subpackage Tests + */ class ezcEventLogSuite extends PHPUnit_Framework_TestSuite { public function __construct() Modified: trunk/EventLog/tests/writers/writer_file_test.php =================================================================== --- trunk/EventLog/tests/writers/writer_file_test.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/tests/writers/writer_file_test.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,5 +1,17 @@ <?php +/** + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package EventLog + * @subpackage Tests + */ +/** + * @package EventLog + * @subpackage Tests + */ class ezcLogFileWriterTest extends ezcTestCase { protected $logFile; @@ -138,7 +150,6 @@ $this->assertEquals(print_r($msg2, true), file_get_contents( $this->getTempDir() . "/default.log") ); $this->assertEquals(print_r($msg, true), file_get_contents( $this->getTempDir() . "/default.log.1") ); } - public function testMaxLogFiles() { Modified: trunk/EventLog/tests/writers/writer_unix_file_test.php =================================================================== --- trunk/EventLog/tests/writers/writer_unix_file_test.php 2006-11-29 07:24:46 UTC (rev 4122) +++ trunk/EventLog/tests/writers/writer_unix_file_test.php 2006-11-29 08:24:18 UTC (rev 4123) @@ -1,5 +1,17 @@ <?php +/** + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @version //autogentag// + * @filesource + * @package EventLog + * @subpackage Tests + */ +/** + * @package EventLog + * @subpackage Tests + */ class ezcLogUnixFileWriterTest extends ezcTestCase { protected $writer; @@ -37,8 +49,19 @@ $this->assertRegExp( $regExp, file_get_contents( $this->getTempDir() ."/default.log" ), "Content of default.log doesn't match with the regular expression."); } - - public static function suite() + + public function testCategoryEmpty() + { + $m = array("message" => "Alien alert.", "type" => 1, "source" => "UFO report", "category" => false); + $extra = array ("Line" => 42); + $regExp = "/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d+ \d+:\d+:\d+ \[Debug\] \[UFO report\] Alien alert. \(Line: 42\)/"; + + $this->writer->writeLogMessage( $m["message"], $m["type"], $m["source"], $m["category"], $extra ); + $this->assertRegExp( $regExp, file_get_contents( $this->getTempDir() ."/default.log" ), + "Content of default.log doesn't match with the regular expression."); + } + + public static function suite() { return new PHPUnit_Framework_TestSuite("ezcLogUnixFileWriterTest"); } |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | 4122 - in trunk/Template: src/parsers/source_to_tst/implementations tests/regression_tests/blocks/incorrect tests/scripts [eZComponents: Trunk]: 00296, Jan Borsodi |
|---|---|
| Next by Date: | 4124 - in experimental/Workflow/src: interfaces nodes [eZComponents: Experimental]: 00296, Sebastian Bergmann |
| Previous by Thread: | 4122 - in trunk/Template: src/parsers/source_to_tst/implementations tests/regression_tests/blocks/incorrect tests/scripts [eZComponents: Trunk]i: 00296, Jan Borsodi |
| Next by Thread: | 4124 - in experimental/Workflow/src: interfaces nodes [eZComponents: Experimental]: 00296, Sebastian Bergmann |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |