Your IP : 216.73.217.64


Current Path : /home3/gp97/php/CLITools/test/
Upload File :
Current File : //home3/gp97/php/CLITools/test/LoggerTest.php

<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'Maarch_CLITools/Logger.php';

class LoggerForTest extends Logger {
    function &__get($key)
    {
        if (property_exists($this, $key)) {
            return $this->$key;
        }
        return null;
    }

    function __set($key, $value)
    {
        $this->$key = $value;
    }

    function __call($name, $arguments)
    {
        return call_user_func_array(Array($this, $name), $arguments);
    }
}

class LoggerTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
       // $this->logger = new LoggerForTest();
        $this->logger = new Logger();
        $this->assertTrue($this->logger instanceof Logger);
    }
    public function tearDown(){
        unset($this->logger);
        $this->assertObjectNotHasAttribute("logger", $this);
    }

    public function testInitialisation()
    {
        $this->assertObjectHasAttribute('threshold_level', $this->logger);
        $this->assertAttributeType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING,'threshold_level', $this->logger);

        $this->assertObjectHasAttribute('mapping', $this->logger);
        $this->assertAttributeType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,'mapping', $this->logger);

        $this->assertObjectHasAttribute('error_levels', $this->logger);
        $this->assertAttributeType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY,'error_levels', $this->logger);
        //$this->assertAttributeContains('DEBUG', 'error_levels', $this->logger);
        $log_levels = array('DEBUG' => 0, 'INFO' => 1, 'NOTICE' => 2, 'WARNING' => 3, 'ERROR' => 4);
        $this->assertAttributeEquals($log_levels, 'error_levels', $this->logger);
    }

/*
    private function testWrite()
    {
        $this->mockLogger = $this->getMock('Logger');

    }

*/

}