Author: Raymond Bosman
Date: 2006-01-12 16:11:57 +0100 (Thu, 12 Jan 2006)
New Revision: 1790
Log:
# Moved files around.
Added:
packages/EventLog/trunk/src/mapper/filterset.php
packages/EventLog/trunk/tests/mapper/filterset_test.php
Removed:
packages/EventLog/trunk/src/map.php
packages/EventLog/trunk/tests/map_test.php
Modified:
packages/EventLog/trunk/src/log_autoload.php
packages/EventLog/trunk/tests/suite.php
Modified: packages/EventLog/trunk/src/log_autoload.php
===================================================================
--- packages/EventLog/trunk/src/log_autoload.php 2006-01-12 15:10:19 UTC
(rev 1789)
+++ packages/EventLog/trunk/src/log_autoload.php 2006-01-12 15:11:57 UTC
(rev 1790)
@@ -11,7 +11,7 @@
return array(
'ezcLog' => 'EventLog/log.php',
- 'ezcLogFilterSet' => 'EventLog/map.php',
+ 'ezcLogFilterSet' => 'EventLog/mapper/filterset.php',
'ezcLogContext' => 'EventLog/context.php',
'ezcLogMessage' => 'EventLog/log_message.php',
'ezcLogWriter' => 'EventLog/interfaces/writer.php',
Deleted: packages/EventLog/trunk/src/map.php
===================================================================
--- packages/EventLog/trunk/src/map.php 2006-01-12 15:10:19 UTC (rev 1789)
+++ packages/EventLog/trunk/src/map.php 2006-01-12 15:11:57 UTC (rev 1790)
@@ -1,79 +0,0 @@
-<?php
-/**
- * File containing the ezcLogMap class.
- *
- * @package EventLog
- * @version //autogentag//
- * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
- * @license http://ez.no/licenses/new_bsd New BSD License
- * @access private
- */
-
-/**
- * Mapping of a mixed variable to an eventType, eventSource and eventCategory.
- *
- * @package EventLog
- * @version //autogentag//
- * @access private
- */
-class ezcLogFilterSet implements ezcLogMapper
-{
- private $rules = array();
-
- private $cache = array();
-
- public function appendRule( $filter )
- {
- $this->rules[] = $filter;
- $this->refreshCache();
- }
-
- public function deleteLastRule()
- {
- if( sizeof( $this->rules ) > 0 )
- {
- array_pop( $this->rules );
- $this->refreshCache();
- return true;
- }
-
- return false;
- }
-
- public function get( $severity, $source, $category )
- {
- // It is likely that the same type of log messages are written after
each other.
- if( isset( $this->cache[ $severity . "_" . $source . "_" . $category ]
) )
- {
- return $this->cache[ $severity . "_" . $source . "_" . $category ];
- }
-
- // It is not cached, yet.
- $total = array();
-
- foreach( $this->rules as $rule )
- {
- if( $rule->isMatch( $severity, $source, $category ) )
- {
- $total = array_merge( $total, $rule->getWriters() );
-
- if( !$rule->shouldContinueProcessing() )
- {
- break;
- }
- }
- }
-
- // Add to cache.
- $this->cache[ $severity . "_" . $source . "_" . $category ] = $total;
- return $total;
- }
-
- protected function refreshCache()
- {
- $this->cache = array();
- }
-
-
-}
-?>
Copied: packages/EventLog/trunk/src/mapper/filterset.php (from rev 1788,
packages/EventLog/trunk/src/map.php)
Deleted: packages/EventLog/trunk/tests/map_test.php
===================================================================
--- packages/EventLog/trunk/tests/map_test.php 2006-01-12 15:10:19 UTC (rev
1789)
+++ packages/EventLog/trunk/tests/map_test.php 2006-01-12 15:11:57 UTC (rev
1790)
@@ -1,263 +0,0 @@
-<?php
-
-
-class ezcLogFilterSetTest extends ezcTestCase
-{
- private $map;
-
- public function setUp()
- {
- $this->map = new ezcLogFilterSet();
- }
-
- public function testMapSimple()
- {
- $rule = new ezcLogFilterRule( new ezcLogFilter( 1 | 2, array("A",
"B"), array("C1") ), "result1", true);
- $this->map->appendRule( $rule );
- $this->assertEquals(array("result1"), $this->map->get(2, "A", "C1") );
-
- $rule = new ezcLogFilterRule( new ezcLogFilter( 1, array( "C" ),
array( "C1") ), "result2", true );
- $this->map->appendRule( $rule );
- //$this->map->map(1, array("C"), array("C1"), "result2");
- $this->assertEquals(array("result2"), $this->map->get(1, "C", "C1") );
- $this->assertEquals(array(), $this->map->get(2, "C", "C1") );
- }
-
- public function testMapMultiple()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter( 1 | 2,
array("A", "B"), array("C1") ), "result1", true ) );
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter( 1,
array("B"), array("C1") ), "result2", true ) );
-
- //$this->map->map(1 | 2, array("A", "B"), array("C1"), "result1");
- //$this->map->map(1, array("B"), array("C1"), "result2");
-
- $this->assertEquals(array("result1", "result2"), $this->map->get(1,
"B", "C1") );
-
- }
-
- public function testMapMultiple2()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
1 | 2, array(), array("Category1") ), "A", true ) );
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
0, array(), array("Category1") ), "B", true ) );
- $this->assertEquals(array("A", "B"), $this->map->get(2, "source",
"Category1"));
- }
-
- public function testMapAll()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter( 0,
array("A", "B"), array("C1") ), "result1", true) );
- $this->assertEquals(array("result1"), $this->map->get(1, "B", "C1") );
- $this->assertEquals(array("result1"), $this->map->get(2, "B", "C1") );
- $this->assertEquals(array(), $this->map->get(2, "C", "C1") );
- }
-
-
- public function testGetObjectString()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter( 1 | 2
| 8, array("Source1", "Source2"), array("Category1") ), "object1", true ) );
- $this->map->appendRule( new ezcLogFilterRule( new
ezcLogFilter( 4 , array("Source2"), array("Category1") ), "object2", true ) );
- $this->map->appendRule( new ezcLogFilterRule( new
ezcLogFilter( 32 , array("Source2"), array("Category1") ), "object2", true ) );
-
- $this->assertEquals(array("object1"), $this->map->get( 2,
"Source1", "Category1" ) );
- $this->assertEquals(array("object1"), $this->map->get( 2,
"Source2", "Category1" ) );
- $this->assertEquals(array(), $this->map->get( 2, "Source2", "aha" )
);
-
- $this->assertEquals(array("object2"), $this->map->get( 4,
"Source2", "Category1" ) );
-
- $this->map->appendRule( new ezcLogFilterRule( new
ezcLogFilter( 4 , array("Source3"), array("Category2") ), "object3", true ) );
-
- $this->assertEquals(array("object3"), $this->map->get( 4,
"Source3", "Category2" ) );
- $this->assertEquals(array(), $this->map->get( 2, "Source3",
"Category2" ) );
-
- // Add extra objects.
- $this->assertEquals(array("object3"), $this->map->get( 4,
"Source3", "Category2" ) );
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
4, array("Source3"), array("Category2") ), "Override", true) );
-
- $this->assertEquals(array("object3", "Override"),
$this->map->get( 4, "Source3", "Category2" ) );
- }
-
-
- public function testGetObjectObject()
- {
- // Add a new object
- $myObject = new SimpleObject();
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
1, array("Source1", "Source2"), array("Category1") ), $myObject, true ) );
-
- // Fetch the object.
- $objArray = $this->map->get(1, "Source2", "Category1");
- $obj = $objArray[0];
- $this->assertNotNull($obj);
- $this->assertSame($obj, $myObject, "Returned object isn't exactly the
same instance.");
- $this->assertEquals("Hello world", $obj->getHelloWorld());
- }
-
- public function testGetVarious()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter( 1 | 2
| 4 | 8, array("A", "B"), array("C") ), "object1", true) );
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
4 , array("Source2"), array("Category1") ), "object2", true ) );
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
32 , array("Source2"), array("Category1") ), "object2", true ) );
-
- $this->assertEquals(array("object1"), $this->map->get( 2, "A", "C") );
- }
-
- public function testMatchAll()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
1 | 2, array(), array("Category1") ), "A", true ) );
- $this->assertEquals(array("A"), $this->map->get(2, "source",
"Category1"));
-
- $this->assertEquals(array(), $this->map->get(4, "source",
"Category1"));
-
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
0, array(), array("Category1") ), "B", true ) );
- $this->assertEquals(array("A", "B"), $this->map->get(2, "source",
"Category1"));
- $this->assertEquals(array( "B" ), $this->map->get(4, "source",
"Category1"));
-
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
0, array(), array() ), "C", true ) );
-
- $this->assertEquals(array("A", "B", "C"), $this->map->get(2, "source",
"Category1"));
- $this->assertEquals(array("C"), $this->map->get(2, "source",
"Category2"));
- }
-
- public function testStopProcessing()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
2, array("A"), array("p") ) , array(), false ) );
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter( 1 | 2,
array("A", "B"), array("p") ), "OneItem", true ) );
- $this->assertEquals( array(), $this->map->get( 2, "A", "p" ) );
- }
-
- public function testMinusOneMatching()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter( 0,
array("Bibit"), array() ), array(), false ) );
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
0, array("Paynet", "Bibit", "Paypal"), array() ), "All Payment systems", true )
);
-
-
- $this->assertEquals( array("All Payment systems"), $this->map->get( 1,
"Paynet", "payment madness" ) );
- $this->assertEquals( array(), $this->map->get( 1, "Content", "payment
madness" ) );
- $this->assertEquals( array(), $this->map->get( 1, "Bibit", "payment
madness" ) );
- $this->assertEquals( array("All Payment systems"), $this->map->get( 1,
"Paypal", "payment madness" ) );
-
- $this->assertEquals( array("All Payment systems"), $this->map->get( 2,
"Paynet", "payment madness" ) );
- }
-
- public function testDeleteLastRule()
- {
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter( 0,
array("Bibit"), array() ), array("First rule"), false ) );
- $this->map->appendRule( new ezcLogFilterRule( new ezcLogFilter(
0, array("Paynet", "Bibit", "Paypal"), array() ), "Second rule", true ) );
-
- $this->assertEquals( array("Second rule"), $this->map->get( 1,
"Paynet", "payment madness" ) );
- $this->assertEquals( array("First rule"), $this->map->get( 1, "Bibit",
"payment madness" ) );
-
- $this->assertTrue( $this->map->deleteLastRule() );
- $this->assertEquals( array(), $this->map->get( 1, "Paynet", "payment
madness" ) );
- $this->assertEquals( array("First rule"), $this->map->get( 1, "Bibit",
"payment madness" ) );
-
- $this->assertTrue( $this->map->deleteLastRule() );
- $this->assertEquals( array(), $this->map->get( 1, "Paynet", "payment
madness" ) );
- $this->assertEquals( array(), $this->map->get( 1, "Bibit", "payment
madness" ) );
-
- $this->assertFalse( $this->map->deleteLastRule() );
-
- }
-
- public function testReuseLogFilter()
- {
- $filter = new ezcLogFilter( 0, array("A"), array() );
- $this->map->appendRule( new ezcLogFilterRule( $filter, array("A"),
false ) );
-
- $filter->source = array("B");
- $this->map->appendRule( new ezcLogFilterRule( $filter, array("B"),
false ) );
-
- $this->assertEquals( array("A"), $this->map->get(1, "A", "z" ) );
- $this->assertEquals( array("B"), $this->map->get(1, "B", "z" ) );
- }
-
-/*
- public function testLoggingMap()
- {
- $this->map->map( 1 | 2 | 4, array(), array(), "logging.log" );
- $this->map->map( 2 | 4, array(), array(), "critical.log" );
- $this->map->map( 0, array("content"), array("templates"),
"content_templates.log");
- $this->map->get(2, "content", "templates");
-
- $this->assertEquals(array("content_templates.log", "logging.log",
"critical.log"), $this->map->get(2, "content", "templates"));
- }
-
- public function testAdd()
- {
- $this->map->map(2 | 4, array(), array(), "Audits");
- $this->map->map( 0, array(), array(), "TheRest");
-
- $this->assertEquals( array("TheRest"), $this->map->get( 1, "A", "B" )
);
- $this->assertEquals( array("Audits", "TheRest"), $this->map->get( 2,
"A", "B" ) );
- $this->assertEquals( array("Audits", "TheRest"), $this->map->get( 4,
"A", "B" ) );
- $this->assertEquals( array("TheRest"), $this->map->get( 8, "A", "B" )
);
- $this->assertEquals( array("TheRest"), $this->map->get( 16, "A", "B" )
);
- }
-
- public function testRemove()
- {
- $this->map->map( 0, array(), array(), "TheRest");
- $this->map->unmap( 2| 4, array(), array(), "TheRest");
-
- $this->assertEquals( array("TheRest"), $this->map->get( 1, "A", "B" )
);
- $this->assertEquals( array(), $this->map->get( 2, "A", "B" ) );
- $this->assertEquals( array(), $this->map->get( 4, "A", "B" ) );
- $this->assertEquals( array("TheRest"), $this->map->get( 8, "A", "B" )
);
- $this->assertEquals( array("TheRest"), $this->map->get( 16, "A", "B" )
);
- }
-
- public function testAddAndRemove()
- {
- $this->map->map(2 | 4, array(), array(), "Audits");
- $this->map->map( 0, array(), array(), "TheRest");
- $this->map->unmap( 2| 4, array(), array(), "TheRest");
-
- $this->assertEquals( array("TheRest"), $this->map->get( 1, "A", "B" )
);
- $this->assertEquals( array("Audits"), $this->map->get( 2, "A", "B" )
);
- $this->assertEquals( array("Audits"), $this->map->get( 4, "A", "B" )
);
- $this->assertEquals( array("TheRest"), $this->map->get( 8, "A", "B" )
);
- $this->assertEquals( array("TheRest"), $this->map->get( 16, "A", "B" )
);
- }
-
- */
- public static function suite()
- {
- return new ezcTestSuite(__CLASS__);
- }
-}
-
-class SimpleObject
-{
- function getHelloWorld()
- {
- return "Hello world";
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-?>
Copied: packages/EventLog/trunk/tests/mapper/filterset_test.php (from rev 1788,
packages/EventLog/trunk/tests/map_test.php)
Modified: packages/EventLog/trunk/tests/suite.php
===================================================================
--- packages/EventLog/trunk/tests/suite.php 2006-01-12 15:10:19 UTC (rev
1789)
+++ packages/EventLog/trunk/tests/suite.php 2006-01-12 15:11:57 UTC (rev
1790)
@@ -1,7 +1,7 @@
<?php
require_once( "log_test.php");
require_once( "log_message_test.php");
-require_once( "map_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");
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components