Changeset 1086

Show
Ignore:
Timestamp:
11/29/07 15:47:21 (9 months ago)
Author:
mikey
Message:

revert commit 1084

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/util/log/stubBaseLogData.php

    r1084 r1086  
    88 */ 
    99stubClassLoader::load('net.stubbles.util.log.stubLogData', 
    10                       'net.stubbles.util.log.stubLogger' 
     10                      'net.stubbles.util.log.stubLogger', 
     11                      'net.stubbles.ipo.session.stubSession' 
    1112); 
    1213/** 
     
    5253     * log appender will not mess up the log data. 
    5354     * 
    54      * @param  string  $target     target where the log data should go to 
    55      * @param  int     $level      optional  log level of the log data 
    56      * @param  string  $sessionId  optional  session id of current user 
     55     * @param  stubSession  $session  the session of the current user 
     56     * @param  string       $target   target where the log data should go to 
     57     * @param  int          $level    optional  log level of the log data 
    5758     */ 
    58     public function __construct($target, $level = stubLogger::LEVEL_INFO, $sessionId = null
     59    public function __construct(stubSession $session, $target, $level = stubLogger::LEVEL_INFO
    5960    { 
    6061        $this->target  = $target; 
    6162        $this->level   = $level; 
    6263        $this->logData = array(date('Y-m-d H:i:s'), 
    63                                (string) $sessionId 
     64                               $session->getId() 
    6465                         ); 
    6566    } 
  • trunk/src/main/php/net/stubbles/util/log/stubLogDataFactory.php

    r1084 r1086  
    3333        $fqClassName = stubRegistry::getConfig('net.stubbles.util.log.class', 'net.stubbles.util.log.stubBaseLogData'); 
    3434        $nqClassName = stubClassLoader::getNonQualifiedClassName($fqClassName); 
    35         if (class_exists($nqClassName, false) === false) { 
     35        if (class_exists($nqClassName, false) == false) { 
    3636            stubClassLoader::load($fqClassName); 
    3737        } 
    3838         
    39         $logData = new $nqClassName($target, $level, $session->getId()); 
    40         if (($logData instanceof stubLogData) === false) { 
     39        $logData = new $nqClassName($session, $target, $level); 
     40        if (($logData instanceof stubLogData) == false) { 
    4141            throw new stubRuntimeException('Configured net.stubbles.util.log.class is not an instance of stubLogData.'); 
    4242        } 
  • trunk/src/test/php/net/stubbles/util/log/stubBaseLogDataTestCase.php

    r1084 r1086  
    11<?php 
    22/** 
    3  * Test for net::stubbles::util::log::stubBaseLogData. 
     3 * Test for net.stubbles.util.log.stubBaseLogData. 
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     
    88 */ 
    99stubClassLoader::load('net.stubbles.util.log.stubBaseLogData'); 
     10Mock::generate('stubSession'); 
    1011/** 
    11  * Test for net::stubbles::util::log::stubBaseLogData. 
     12 * Test for net.stubbles.util.log.stubBaseLogData. 
    1213 * 
    1314 * @package     stubbles 
     
    1718{ 
    1819    /** 
    19      * assure that data is handles as expected 
     20     * instance to test 
     21     * 
     22     * @var  stubBaseLogData 
    2023     */ 
    21     public function testWithSessionId() 
     24    protected $baseLogData; 
     25     
     26    /** 
     27     * set up the test environment 
     28     */ 
     29    public function setUp() 
    2230    { 
    23         $baseLogData = new stubBaseLogData('bar', stubLogger::LEVEL_INFO, 'foo'); 
    24         $this->assertEqual($baseLogData->getLevel(), stubLogger::LEVEL_INFO); 
    25         $this->assertEqual($baseLogData->getTarget(), 'bar'); 
    26         $baseLogData->addData("ba\r\nz" . stubLogData::SEPERATOR . 'vvv'); 
    27         $data = explode(stubLogData::SEPERATOR, $baseLogData->get()); 
    28         $this->assertEqual($data[1], 'foo'); 
    29         $this->assertEqual($data[2], 'ba<nl>zvvv'); 
     31        $mockSession = new MockstubSession(); 
     32        $mockSession->setReturnValue('getId', 'foo'); 
     33        $this->baseLogData = new stubBaseLogData($mockSession, 'bar'); 
    3034    } 
    31  
     35     
    3236    /** 
    3337     * assure that data is handles as expected 
    3438     */ 
    35     public function testWithoutSessionId() 
     39    public function testData() 
    3640    { 
    37         $baseLogData = new stubBaseLogData('bar'); 
    38         $this->assertEqual($baseLogData->getLevel(), stubLogger::LEVEL_INFO); 
    39         $this->assertEqual($baseLogData->getTarget(), 'bar'); 
    40         $baseLogData->addData("ba\r\nz" . stubLogData::SEPERATOR . 'vvv'); 
    41         $data = explode(stubLogData::SEPERATOR, $baseLogData->get()); 
    42         $this->assertEqual($data[1], ''); 
     41        $this->assertEqual($this->baseLogData->getLevel(), stubLogger::LEVEL_INFO); 
     42        $this->assertEqual($this->baseLogData->getTarget(), 'bar'); 
     43        $this->baseLogData->addData("ba\r\nz" . stubLogData::SEPERATOR . 'vvv'); 
     44        $data = explode(stubLogData::SEPERATOR, $this->baseLogData->get()); 
     45        $this->assertEqual($data[1], 'foo'); 
    4346        $this->assertEqual($data[2], 'ba<nl>zvvv'); 
    4447    }